Please help | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Please help

Can somebody please break this down for me, what the mathematical process is of the following var x = “2*2” var y= 4 var z = eval(x+y) alert(z)

15th Feb 2019, 8:07 PM
Luke Sandford
3 Answers
+ 2
// Because you make the 1st variable with a string and he can not make the operation. But if you use int, JavaScript can make the operation as a calculator.
15th Feb 2019, 8:22 PM
program
program - avatar
+ 4
hi Luke Sandford ok so x is a string value then y is an int value z evaluates to a string because it is the first value so the output is 2*24 i hope this helps
15th Feb 2019, 8:15 PM
Ollie Q
Ollie Q - avatar
+ 2
thanks guys
15th Feb 2019, 8:35 PM
Luke Sandford