Skip to content

Instantly share code, notes, and snippets.

@slopeofhope81
Created January 24, 2014 13:52
Show Gist options
  • Save slopeofhope81/8597620 to your computer and use it in GitHub Desktop.
Save slopeofhope81/8597620 to your computer and use it in GitHub Desktop.
//Write a program to ask yourself, using prompt, what the value of 2 + 2 is. If the answer is "4", use alert to say something praising. If it is "3" or "5", say "Almost!". In other cases, say something mean.
//Write a program to ask yourself, using prompt, what the value of 2 + 2 is. If the answer is "4", use alert to say something praising. If it is "3" or "5", say "Almost!". In other cases, say something mean.
answer = Number(prompt("What is the value of 2+2?"));
if (answer === 4) {
alert("you are right!");
} else if (Math.abs(4 - answer) > 2) {
alert("you did okay");
} else {
alert("lets go back to kindergarten");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment