PencilCoder

Math, Mod, and More!

Goals:

  • Learn about and use the mod and integer division operators, and explore different computational resources from the Math object

Coding Snippets:

  • coding snippets
  • Use the integer division operator, //, to compute the quotient resulting from the division of one integer by another.
  • Use the modulus (or mod) operator, %, to compute a remainder from division.
  • Cause expressions inside strings to be evaluated using string interpolation by enclosing them inside of #{}.

Math and Computer Concepts:

  • Blank space Four terms are used to describe the division of one value by another:
  • In addition to the division operator ( / ), Javascript provides the operators // and % to provide direct access to the quotient and the remainder, respectively.
  • Math is a built-in Javascript object with properties and functions for mathematical constants and functions, including:
    Math.ceil(5.2)  6
    Math.floor(4.6)  4
    Math.round(4.6)  5
    Math.max(6, 2, -3.5, 1)  6
    Math.sign(-3) -1
    Math.abs(-3)  3
    Math.sqrt(9)  3
    Math.PI  3.14159....

Activities:

Save each of the following in a folder called Math.