Learning JS Course @Sololearn - Day24

Photo by Andrew Neel on Unsplash

Learning JS Course @Sololearn - Day24

·

2 min read

Today #day24 of #100daysofcode, I have completed 2 lessons and a practice program in JS. @Sololearn

Math Operators

Arithmetic operators

  • the arithmetic operators are +,-,/,*,%,++,--,,,,

Note:

  • \ is escape character.
  • eval() function text string argument can perform arithmetic operations. Example:
var x = 10 + 5;
document.write(x);

document.write("<br>"+eval("5+9/6*4%79-862"))

Code: Output

Note:

  • multiplying string type of number value with a number will give output.
  • but multiplying string type of string value with a number will result error i.e NaN
    • in Python multiplying and number with a string type of string value multiply the string value in the house
  • you can add a string type of number value to a number.
  • you can add string type of string value to a number.
var x = 10 * 5;
document.write("10 * 5\ = "+x);

document.write("<br>"+"\"10\" * 5\ = "+"10"*5);
document.write("<br>"+"\"Hi\"*5\ = "+"Hi"*5);
document.write("<br>"+"\"10\"+5\ = "+"10"+5);
document.write("<br>"+"\"Hi\"+5\ = "+"Hi"+5);

Code: Output

increment and decrement operators

  • the increment operator increases the value it's operate by one,a=0,b=0,a++ then a=1.

Note:

  • a=b++ --> a=0,b=1
  • a=++b--> a=1,b=1

Assignment operators

  • =,+=,-=,*=,/=,%=

Image

  • 9. day24 lesson 7 completed.png

  • 11. day24 lesson 8 completed.png

Conclusion

  1. Arithmetic operators.
  2. Increment and decrement operators.
  3. Assignment operators.

References: Sololearn

Author: Dheeraj.y

Connect with me:

Did you find this article valuable?

Support dheerajy blog by becoming a sponsor. Any amount is appreciated!