Below code output is 24 please how it is..ask in challenge in Java script . | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Below code output is 24 please how it is..ask in challenge in Java script .

Console.log(" 2"+"2"*"2");

7th May 2020, 1:37 PM
Ajit Pawar
2 Answers
+ 4
Actually, because of order of operations multiplication is done first. ("2" + "2" *"2") = "2" + "4" = 24 because + does string concatenation. "22" * 2 = 44.
7th May 2020, 2:29 PM
Bahhaⵣ
Bahhaⵣ - avatar
+ 2
Edit: Makes sense, so the * operator has a higher precedence than the + operator even when the + operator morphs into a string concatenation? Interesting.
7th May 2020, 3:21 PM
Damyian G
Damyian G - avatar