Skip to main content

✏️ Practice: Arithmetic

Goal: In the Arithmetic lesson, we learned:

  • How to access the DevTools Console.
  • Addition, subtraction, multiplication, and division using JavaScript operators.
  • NaN means not a number but is actually considered a type of number.
  • Infinity represents infinity and is also a type of number.

Begin getting comfortable with these concepts by completing the practice exercises listed below. Soon enough, they'll be second nature!

Warm Up​


Make sure you understand the following before moving on:

  • What is an expression in JavaScript?
  • How can we access the DevTools console?
  • When might we see NaN?

Code​


Complete the following exercises to practice arithmetic in JavaScript. If you are with a pair, switch off between every section (i.e.: "Add", "Subtract", etc.) or between every prompt (e.g.: "77 to 99", "99 from 665").

Add:​

  • 77 to 99
  • 34 to 1233
  • -53 to 99

Subtract:​

  • 99 from 665
  • 555 from 23
  • 6,348,709,234 from 87,023,984,709,871,234

Multiply:​

  • 89 and 54
  • 932 and 1,900
  • -34 and 8

Divide:​

  • 1008 by 7
  • 9,870,834,205,987 by 324
  • A number by 0.
  • 0 by 0.