[SOLVED] Javascript eval("1"+"2*2") == 24 ???? | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 4

[SOLVED] Javascript eval("1"+"2*2") == 24 ????

Given var a = "1" var b = "2*2" console.log(eval(a+b)) I don't understand why the result is 24 and not 14 ūüė≤

16th Apr 2021, 12:17 PM
David Ord√°s
David Ord√°s - avatar
2 Réponses
+ 10
+ concat 2 strings, so "1" + "2*2" "12*2"
16th Apr 2021, 12:20 PM
šĹ†Áü•ťĀŹŚČáԾƜąĎšĻüśėĮ
šĹ†Áü•ťĀŹŚČáԾƜąĎšĻüśėĮ - avatar
+ 1
Thanks CarrieForle first concatenate and then eval
17th Apr 2021, 12:51 AM
David Ord√°s
David Ord√°s - avatar