javascript - My First Program Wont Cooperate -


so after short time on codeacademy trying write first program , want ask user if ready when are, flip coin 1,000 times , record results. after 1 question here thought had kinks worked out , changed 'while' loop 'for' loop. worked , made code more simple wouldn't work if user selected 'no' when asked first time if ready. fix tried add second 'for' loop , program wont run @ , there error on line 16 introduce 'else' statement. did wrong here? suggestions on easier way user have chance change answer 'yes' on second (or repeated) prompting , still run original loop? thank you.

var userready = prompt("are ready simulation of 1,000 coin flips?! probability. randomness.");  var heads = 0;  var tails = 0;  if (userready.tolowercase() === "yes") {     (i = 0; <= 1000; i++) {         var coinface = math.floor(math.random() * 2);         if (coinface === 0) {             heads++;         } else {             tails++;         }     } } else {     confirm("oh come on, live little!");     var comeon = prompt("are ready now?");     if (comeon.tolowercase() === "yes") {         (j = 0; j <= 1000; j++) {             var coinface = math.floor(math.random() * 2);             if (coinface === 0) {                 heads++;             } else {                 tails++;             }         }     } else {         confirm("where sense of adventure?");      }       confirm("i came heads " + heads + " times!");     confirm("i came tails " + tails + " times!"); 

missing last } outer else block.

it

} else {     // rest of code     confirm("i came heads " + heads + " times!");     confirm("i came tails " + tails + " times!"); } 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -