
“JavaScript Operators Explained Simply”
Arithmetic operators “Arithmetic operators perform basic mathematical operations like addition, subtraction, multiplication, and division.” 👉 Use image showing: + - * / % ** let a = 10 , b = 3 ; console . log ( " Addition: " , a + b ); // 13 console . log ( " Subtraction: " , a - b ); // 7 console . log ( " Multiplication: " , a * b ); // 30 console . log ( " Division: " , a / b ); // 3.33 console . log ( " Remainder: " , a % b ); // 1 console . log ( " Power: " , a ** b ); // 1000 console . log ( " Floor: " , Math . floor ( a / b )); // 3 Ok, but the number and string complain about what happened Number + String Converts number to string and joins let a = 10; let b = "5"; let result = a + b; console.log(result); // "105" 👉 Important: - (minus) is NOT like + It always tries to convert values to numbers. Subtraction let a = 10 ; let b = " 5 " ; let result = a - b ; console . log ( result ); // "5" ❌ Invalid String let a = " hello " ; let b = 5 ; console . log ( a - b ); // NaN Assignmen
Continue reading on Dev.to JavaScript
Opens in a new tab


