+ 2

Help me please!!

var x = 4; var y = 5; var d = 4 + z; var z = y - x; var c = x + z + d + y; alert(c); Why result is NaN, not 15? I don't understand !!

13th Aug 2017, 10:11 AM
Trưởng Nguyễn
Trưởng Nguyễn - avatar
7 Antworten
+ 5
z is not defined
13th Aug 2017, 10:35 AM
Krafty Coder
Krafty Coder - avatar
+ 4
you are trying to add z before declaring it. Move var d = 4+z after the line var z = y-x
13th Aug 2017, 10:14 AM
Salekin
Salekin - avatar
+ 2
He is very correct, your placement was just a bit off, keep up the energy and stay invested. var x = 4; var y = 5; var z = y - x; var d = 4 + z; var c = x + z + d + y; alert(c);
13th Aug 2017, 10:18 AM
Michael
Michael - avatar
+ 2
Hey,are you related to a guy named vy nguyen?
17th Aug 2017, 12:11 AM
Samuel Adams
Samuel Adams - avatar
+ 2
No. I don't know who named vy nguyen. #Samuel Adams
17th Aug 2017, 12:14 AM
Trưởng Nguyễn
Trưởng Nguyễn - avatar
+ 1
Oh. Thank you very much!!
13th Aug 2017, 10:15 AM
Trưởng Nguyễn
Trưởng Nguyễn - avatar
0
move z=y-x before d=4+z
19th Sep 2017, 11:50 AM
Nawab Khan Jadoon
Nawab Khan Jadoon - avatar