Advertisement
Crevice

Conditional Challenges 3

Nov 5th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.35 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.    <meta charset="UTF-8">
  5.    <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6.    <meta http-equiv="X-UA-Compatible" content="ie=edge">
  7.    <title>Document</title>
  8.    <script>
  9.        //#1
  10.        //declare four variables, num1, num2, operator, and result
  11.        //num1 and num2 will contain numeric values
  12.        //operator will contain a math operator in a string (either "+","-","/", or "*")
  13.        //result will contain null
  14.  
  15.        //#2
  16.        //declare a switch statement which
  17.        //adds, subtracts, multiplies, or divides the two numbers based on the operator you declared
  18.        //stores the result of the calculation in the result variable you created in the previous step
  19.        //and console logs that result once the switch has completed running
  20.        //have the switch's default statement console log "Invalid operator"
  21.        //#3
  22.        // Bonus: declare a conditional statement which replicates the functionality of the conditional
  23.        //you created in the previous step.
  24.        //if an invalid operator or number is used, you should console log "invalid operator or number was used"
  25.        //#4
  26.        //Bonus: create a similar switch statement that uses fall through to
  27.        //allow the use of "x" and "X" for multiplication
  28.    </script>
  29. </head>
  30. <body>
  31. </body>
  32. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement