Monty Hall problem: Difference between revisions

Line 1,637:
// results
return {
stayWins: chosenWins + ' / ' + tests + ' ' + (100 * chosenWins / tests) + '%',
switchWins: switchWins + ' / ' + tests + ' ' + (100 * switchWins / tests) + '%'
}
}
Line 1,647:
<lang javascript>
montyhall(1000, 3)
Object {stayWins: "349 / 1000 34.9%", switchWins: "651 / 1000 65.1%"}
montyhall(1000, 4)
Object {stayWins: "247253 / 1000 2425.73%", switchWins: "351 / 1000384 3538.14%"}
montyhall(1000, 5)
Object {stayWins: "205 / 1000202 20.52%", switchWins: "268 / 1000265 26.85%"}
</lang>
 
Anonymous user