Adding Monty Hall problem
This commit is contained in:
21
monty_hall.js
Normal file
21
monty_hall.js
Normal file
@@ -0,0 +1,21 @@
|
||||
const choices = {
|
||||
choice0: false,
|
||||
choice1: false,
|
||||
choice2: false
|
||||
};
|
||||
|
||||
const getRandomChoice = (max) => {
|
||||
return Math.floor(Math.random() * max);
|
||||
}
|
||||
|
||||
const setTrue = () => {
|
||||
let randValue = getRandomChoice(3);
|
||||
let key = `choice${randValue}`
|
||||
choices[key] = true;
|
||||
}
|
||||
|
||||
setTrue();
|
||||
|
||||
// let userChoice = prompt("Quelle porte choisissez-vous ? 1, 2 ou 3 ? ", 2);
|
||||
|
||||
if
|
||||
Reference in New Issue
Block a user