Javascript expressions | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 9

Javascript expressions

Hi could someone help me understand the logic here. If this question is not within guidelines i will gladly remove it. It is from the challenge questions. So here goes Var a = 1; Var b = 2; Var d = "8"; Var c = d+(a= b+1)-d; Alert(c); Output 75 Please explain the formula here var c.

10th Sep 2020, 8:58 AM
J 12323123
J 12323123 - avatar
2 Antworten
+ 8
Thank you!!!
10th Sep 2020, 9:22 AM
J 12323123
J 12323123 - avatar
+ 2
first the value in bracket is evaluated ,a=3, expression is now left as d+a-d (I am assuming that's how it works as I haven't seen assigning in between an expression) "8"+3-"8" is reduced to "83"-"8" due to concatenation and conversion of 3 to string ,which results in 75 as JavaScript will implicitly convert 83 and 8 to integer
10th Sep 2020, 9:15 AM
Abhay
Abhay - avatar