//JavaScript can some please explain to me how this code equal 24 | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 1

//JavaScript can some please explain to me how this code equal 24

var a="1"; var b="2*2"; console.log(eval(a+b)); Output //24 Why Please explain

2nd Jul 2019, 9:12 PM
George S Mulbah II
George S Mulbah II - avatar
1 Resposta
+ 1
George S Mulbah If you add this line to your snippet above - console.log(a+b) The output this would be 12*2 and this what the eval function see also. And of course, the rest is math.
2nd Jul 2019, 10:00 PM
ODLNT
ODLNT - avatar