Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <meta http-equiv="X-UA-Compatible" content="ie=edge">
- <title>Document</title>
- <script>
- //#1
- //declare four variables, num1, num2, operator, and result
- //num1 and num2 will contain numeric values
- //operator will contain a math operator in a string (either "+","-","/", or "*")
- //result will contain null
- //#2
- //declare a switch statement which
- //adds, subtracts, multiplies, or divides the two numbers based on the operator you declared
- //stores the result of the calculation in the result variable you created in the previous step
- //and console logs that result once the switch has completed running
- //have the switch's default statement console log "Invalid operator"
- //#3
- // Bonus: declare a conditional statement which replicates the functionality of the conditional
- //you created in the previous step.
- //if an invalid operator or number is used, you should console log "invalid operator or number was used"
- //#4
- //Bonus: create a similar switch statement that uses fall through to
- //allow the use of "x" and "X" for multiplication
- </script>
- </head>
- <body>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement