0
How do I make a quiz game with textarea?
I tried this code, but it didn’t work: <p>Sample question? Say yes or no.</p> <textarea id=“write1” placeholder=“write your answer here” cols=“15” rows=“1”></textarea> <button onclick=“answer()”>Answer</button> <script> function answer(){ if (write1 == “yes”){ alert(“you\’re correct!”); } else{ alert(“nope”) } } It always turned out as “nope” even if I typed in yes. I need help
3 Respuestas
+ 1
Hi rac0208 ,
You're doing great!
It's wonderful to see you've been using the Code Playground too! :) Did you know you can post a link to your code in the discussion? Would you mind doing that for the code you put in your original post, plus any modifications you've tried? (Makes it a lot easier for us to help out when we're not in front of a desktop/laptop and working off the mobile app.)
In the meantime, this link might cover a bit more ground:
https://www.w3schools.com/jsref/dom_obj_textarea.asp
Looking forward,
-- Janning.
0
Hi rac0208 !
So that I'm not taking away from you the fun of learning, maybe ask yourself:
What does the script think "write1" is right now?
Am I doing a good job telling the script what "write1" is?
:)
0
So, Janning, I’m identifying write1 as the whole box, not the text i put inside it. I just don’t know how to do that...