+ 6

Please explain me why value of "y" doesn't change after the "foo" function?

https://code.sololearn.com/W30SlRFoiIRn/?ref=app

8th Nov 2017, 4:58 PM
Vahe Khachatryan
Vahe Khachatryan - avatar
4 Answers
+ 10
y = 7; function foo() { y = 4; } foo(); alert(y);
8th Nov 2017, 5:30 PM
Kamil
Kamil - avatar
+ 7
because you only change the value of x, there is only one statement that changes a variable it's x=4;
8th Nov 2017, 5:05 PM
Kamil
Kamil - avatar
+ 7
Ok, but how to change the value of y?
8th Nov 2017, 5:13 PM
Vahe Khachatryan
Vahe Khachatryan - avatar
0
Thank you very much
8th Nov 2017, 5:34 PM
Vahe Khachatryan
Vahe Khachatryan - avatar