Console & eval | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Console & eval

Hi everyone, please why is the answer of this 24? var a= "1"; var b= "2*2"; console.log(eval(a+b));

26th Oct 2021, 5:41 AM
Okonte Richard-Koko
Okonte Richard-Koko  - avatar
2 Answers
+ 3
Thanks a lot guys for breaking it down. I really appreciate it and i understand it now.🤗
26th Oct 2021, 8:30 AM
Okonte Richard-Koko
Okonte Richard-Koko  - avatar
+ 1
a+b = 1(2*2) = 12*2 = 24
26th Oct 2021, 6:02 AM
Kashyap Kumar
Kashyap Kumar - avatar