Northcentral Technical College Introduction To Programming
10-152-310
Introduction to Programming with JavaScript NTC 10-152-310

Learning Plan 3 Operators That Multiply and Divide

# Operators That Multiply and Divide

#### File: /Learning Plan 3/multiplyDivideOperators.html

> These are familiar to anyone who has even used a spreadsheet program.

### Readings

- Head First JavaScript
  - Chapter

### The Multiplicative Operators

- The asterisk `(*)` is used for multiplication
- The forward slash `(/)` is used for division
- The percent sign `(%)` is the modulo operator. (What's this, you ask? Don't worry, we'll go over it in good detail.)

### Using the Multiplicative Operators

#### Multiplying

- You can multiply numbers and number variables.
- When you multiply a number and a string the string will be converted to a number by JavaScript.
- Even when you multiply a string by a string JavaScript will convert the strings to numbers, if it can.

#### Dividing

- You can divide numbers and variables.
- When you divide a number and a string the string will be converted to a number by JavaScript.
- Even when you divide a string by a string JavaScript will convert the strings to numbers, if it can.

#### Modulo Operator

- The modulo operator is very simple. Remember back in elementary school when you learned to do division manually? They called it "long division" in my era. The modulo operator just gives you the remainder when you divide two numbers.
- Here's how we code it in JavaScript

- And here's more examples

### Lab Time

- This lab is all about multiplying and dividing. And you thought you wouldn't have to do that anymore in school! 3.2 Lab 2
  - 3.2 Assignment 2