This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
var codeRoulette = function() { | |
var guess, answer; | |
guess = prompt("Welcome to Code Roulette. Please guess the number I am thinking of between 0 and 10. You have 3 chances to guess the correct number or you die."); | |
answer=Math.floor(Math.random()*11); | |
if(guess == answer) { | |
return"That is correct. Congratulations. You win $1 million."; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// NESTED FOR LOOP: | |
for(var i=0;i<3;i++) { //declare i=0; stop if i >=3; increase i by 1 after each run | |
for (var j=0;j<2;j++) { //declare j=0; stop if j>=2; increase j by 1 after each run | |
console.log(i+" "+j) //prints i and j for each iteration | |
} | |
} | |
//this should returns: | |
// |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
var guess, answer, difference | |
var answer = 411 | |
for (i=0; i<10; i++) { | |
guess = prompt("How many licks does it take to get to the Tootsie Roll center of a Tootsie Pop?","Enter answer here"); | |
if (guess == 411) { | |
alert("Congrats, You win life time supply of Tootsie Rolls!") | |
break; |
NewerOlder