2.2 Arithmetic Operators
2️⃣

2.2 Arithmetic Operators

2.2 Arithmetic Operators

These are just your typical math operators. Very important in any programming language. Know them well!
let x = 5; let y = 10; x + y; //returns 15 y - x; //returns 5 x * y; //returns 50 y / x; //returns 2 x % 2; //returns 1 x++; //returns 6 x--; //returns 4
 
+ Operator performs concatenation operation when one of the operands is of string type.
The following example shows how + operator performs operation on operands of different data types.
let a = 5, b = "Hello ", c = "World!", d = 10; a + b; // "5Hello " b + c; // "Hello World!" a + d; // 15
⚠️
When concatenating a number with a string, it won't actually do math. Only when a number is added with another number will it do math.

Practice

You can add practice problems here if you want. Follow the format below.
 
⚖️
Copyright © 2021 Code 4 Tomorrow. All rights reserved. The code in this course is licensed under the MIT License. If you would like to use content from any of our courses, you must obtain our explicit written permission and provide credit. Please contact classes@code4tomorrow.org for inquiries.