+ 1

Hi! Could anyone please help tell me why my function isn't displaying the " What's up? " response?

I want the if statement in my function to display "What's up?" in the round circle but it keeps displaying the else statement. What is my mistake? Please help me. https://code.sololearn.com/WnDUantW1qTo/?ref=app

9th Aug 2022, 11:15 PM
Sam
Sam - avatar
4 Respostas
+ 7
Sam Your function can't access the user input because it is external function reply(){ var userinput= inputBox2.value; if (userinput == "Sam"){ document.getElementById("AnswerCircle").innerHTML="Whats up?"; } else{ document.getElementById("AnswerCircle").innerHTML="Not working"; } }
10th Aug 2022, 12:48 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 4
A var can be global, but your function would have to specifically call it
10th Aug 2022, 4:54 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 2
Thanks you very much. It is working now. Why was it that the var userinput wasn't being access by the function reply(). I taught var variables were global. Thanks again for the help.
10th Aug 2022, 2:07 AM
Sam
Sam - avatar
0
Thanks
10th Aug 2022, 12:03 PM
Sam
Sam - avatar