var door1 = "Goat"; var door2 = "Goat"; var door3 = "Goat"; var win = 0; var fail = 0; function random10() { var abc10 = Math.floor(Math.random() * 2); return abc10; } function random123() { var abc123; var abc = Math.floor(Math.random() * 100); if (abc > 66) { abc123 = 3; } else if (abc > 33) { abc123 = 2; } else { abc123 = 1; } return abc123; } for (i=0;i>999;i++) { console.log(i); var randommellem123 = random123(); var switchdoor = random10(); switch (randommellem123) { case 1: door1 = "Car"; break; case 2: door2 = "Car"; break; case 3: door3 = "Car"; break; default: console.log("ERROR!"); break; } var doorchoose = random123(); if (doorchoose == 1) { if (door2 == "Goat") { //flipdoor2 if (switchdoor == 1) { if (door3 == "Goat") { fail++; } else { win++; } } else { if (door1 == "Goat") { fail++; } else { win++; } } } else { //flipdoor3 if (switchdoor == 1) { win++; } else { fail++; } } } if (doorchoose == 2) { if (door1 == "Goat") { //flipdoor1 if (switchdoor == 1) { if (door3 == "Goat") { fail++; } else { win++; } } else { if (door2 == "Goat") { fail++; } else { win++; } } } else { //flipdoor3 if (switchdoor == 1) { win++; } else { fail++; } } } if (doorchoose == 3) { if (door1 == "Goat") { //flipdoor1 if (switchdoor == 1) { if (door2 == "Goat") { fail++; } else { win++; } } else { if (door3 == "Goat") { fail++; } else { win++; } } } else { //flipdoor2 if (switchdoor == 1) { win++; } else { fail++; } } } } console.log(win); console.log(fail);
var door1 = "Goat"; var door2 = "Goat"; var door3 = "Goat"; var win = 0; var fail = 0; function random10() { var abc10 = Math.floor(Math.random() * 2); return abc10; } function random123() { var abc123; var abc = Math.floor(Math.random() * 100); if (abc > 66) { abc123 = 3; } else if (abc > 33) { abc123 = 2; } else { abc123 = 1; } return abc123; } for (i=0;i<999;i++) { console.log(i); var randommellem123 = random123(); var switchdoor = random10(); switch (randommellem123) { case 1: door1 = "Car"; break; case 2: door2 = "Car"; break; case 3: door3 = "Car"; break; default: console.log("ERROR!"); break; } var doorchoose = random123(); if (doorchoose == 1) { if (door2 == "Goat") { //flipdoor2 if (switchdoor == 1) { if (door3 == "Goat") { fail++; } else { win++; } } else { if (door1 == "Goat") { fail++; } else { win++; } } } else { //flipdoor3 if (switchdoor == 1) { win++; } else { fail++; } } } if (doorchoose == 2) { if (door1 == "Goat") { //flipdoor1 if (switchdoor == 1) { if (door3 == "Goat") { fail++; } else { win++; } } else { if (door2 == "Goat") { fail++; } else { win++; } } } else { //flipdoor3 if (switchdoor == 1) { win++; } else { fail++; } } } if (doorchoose == 3) { if (door1 == "Goat") { //flipdoor1 if (switchdoor == 1) { if (door2 == "Goat") { fail++; } else { win++; } } else { if (door3 == "Goat") { fail++; } else { win++; } } } else { //flipdoor2 if (switchdoor == 1) { win++; } else { fail++; } } } } console.log(win); console.log(fail);
while(true) { //vil køre for evigt }