Javascript for Statement Roll a Six-Sided Die 6000 times
let frequency1 = 0; let frequency2 = 0; let frequency3 = 0; let frequency4 = 0; let frequency5 = 0; let frequency6 = 0; let face;//from w w w. ja va2 s . com // roll die 6000 times and accumulate results for ( let roll = 1; roll <= 6000; roll++ ) { face = Math.floor( 1 + Math.random() * 6 ); switch ( face ) { case 1: ++frequency1; break; case 2: ++frequency2; break; case 3: ++frequency3; break; case 4: ++frequency4; break; case 5: ++frequency5; break; case 6: ++frequency6; break; } // end switch } // end for console.log(frequency1); console.log(frequency2); console.log(frequency3); console.log(frequency4); console.log(frequency5); console.log(frequency6);