+ 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
4 Answers
+ 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";
}
}
+ 4
A var can be global, but your function would have to specifically call it
+ 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.
0
Thanks