0

This if else statement is a flawless masterpiece but it won't work

Run the code. Press "Continue", then press "Talk to them". Pressing the second button will call a function which will edit a var, and then call another function with an if/else in it. (see first 2 functions) I see 2 ways to solve the issue (see //comments). Though, I'm really curious on why the code written like that won't work. https://code.sololearn.com/Wy9odFDG8l2F

26th Feb 2019, 5:42 PM
Matteo Consolaro
Matteo Consolaro - avatar
3 ответов
+ 4
You redefine the variable "spoken" in each function so that it will be local to that function. Remove the "var"
26th Feb 2019, 5:52 PM
Anna
Anna - avatar
+ 2
In that case it was flawed.
27th Feb 2019, 9:23 AM
Abdulhaq
Abdulhaq - avatar
0
Thanks Anna. So declaring a var again will make a local variable. That's good to know. I always get stuck on the simplest things lol.
26th Feb 2019, 6:41 PM
Matteo Consolaro
Matteo Consolaro - avatar