Math Quiz Worksheet

Step 1

  1. Ask user to choose from 3 types of quizzes (+, -, *) with prompt()
  2. Declare variable: operation to store the input
  3. Declare variable: score and set it to 0
  4. Declare 4 variables: num1, num2, ans, userAns

Step 2

  1. Select 2 random numbers using Math.random() * 10
  2. Use Math.round() to round numbers to integer
  3. Assign numbers into num1 and num2

Step 3

  1. Detect question type
  2. Set ans variable according to question
  3. Ask question using prompt() and store it to userAns

Step 4

  1. Check answer
  2. If correct, add 1 to score and inform user through console.log()
  3. Else, minus 1 from score and inform user through console.log()

Step 5

  1. Repeat for at least 20 questions
  2. Stop the loop if the user click Cancel

Step 6

  1. Display total score with alert()