JAVASCRIPT · ОСНОВЫ · LESSON 05

Count the purchase.

Addition and multiplication · about 12 minutes

Learning with progressRead the summary for free. To save the work, log in to the account.
STEP 1

Counting signs

JavaScript knows + for addition and * for multiplication.

console.log(2 * 3);

✦ That'll be 6.

STEP 2

Save the score.

First, the program will count to the right of =, then save the result under the name.

const total = 2 * 3;
console.log(total);

✦ total stores 6.

IN-CLASS PRACTICE

Type the code yourself

Type an example manually. Check the names, brackets and signs.

const price = 4;
const count = 3;
console.log(price * count);
Open the editor for class work
HOMEWORK

Solve it yourself

The price of price is 5, the number of count is 4. Save their product in const total and output total.

The answer is hidden. Use similar examples from the lesson notes.

Opening up your homework