We can perform multiple calculations using operators in the same line of code:
console.log(3 - 4 + 6); // Prints 5 console.log(5 + 2 - 3); // Prints 4 console.log(2 * 5 + 1); // Prints 11 console.log(4 / 2 * 5); // Prints 10
We can also use variables:
let num1 = 5; let num2 = -1; console.log(2 * num1 * num2); // Prints -10 console.log(num1 + num2 - 3); // Prints 1 console.log(20 / num1 + num2); // Prints 3 console.log(num1 / 5 * num2); // Prints -1
Assignment
Follow the Coding Tutorial and let's practice with mathematical expressions!
Hint
Look at the examples above if you get stuck.
Free plan: 30 tutor messages. PRO is unlimited.
Saved
Ctrl + Enter to check
