charr1309 / JavaScript_Selection_Statements

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JavaScript_Selection_Statements

Exercise 1

  1. Initialize an integer to represent a favorite number and assign a value with a number of your choosing or you can assign a random number to this variable.
  2. Use window.prompt() to ask the user to input a number, and store the result in a variable
  3. Create an if-statement that if the guessed number is below the initial value, print out “too low”.
  4. Create an else-if statement that if the number is higher than the initial value, print out “too high”.
  5. Create an else statement that prints out “Congratulations!!!”.

Exercise 2

  1. Declare a variable named userInput2 (or whatever topic you’ll ask about) and set the value to window.prompt(“Whatever question you want to ask here”).
  2. Inside of the parentheses, ask a question on whatever (appropriate) topic you’d like.
  3. Create a switch-case statement with 5+ cases and a default case.
  4. Log a response to the console depending on the value of userInput2.

About


Languages

Language:JavaScript 55.7%Language:HTML 24.7%Language:CSS 19.6%