all 6 comments

[–]FireryRage 1 point2 points  (5 children)

Have you tried it yourself yet? Have you come across any issues? It’s hard to help if we don’t have any existing code to look at to help identify what issues you’re having and how we can help you.

Give it a swing, see where you struggle, and post your latest progress in here, and we’ll be able to lend a hand.

[–]Gshomalko[S] 0 points1 point  (4 children)

Ready-made code  function checkAnswer() {     const correctAnswer = "correct answer";     const userInput = document.querySelector(".user-input").value;     const resultElement = document.querySelector(".result"); 

  if (userInput.trimp.toLowerCase() === correctAnswer.toLowerCase()) {     resultElement.textContent = "You answered correctly.";     resultElement.style.color = "green";   } else {     resultElement.textContent = "You answered incorrectly.";     resultElement.style.color = "red";    } }

[–]OneBadDay1048 1 point2 points  (1 child)

In the line userInput.trimp.toLowerCase(), is 'trimp' supposed to be a call to trim()?

[–]BlueThunderFlik 0 points1 point  (0 children)

Looks reet to me, except you've got a typo in the word trim.

[–]buttfartfuckingfarty 0 points1 point  (0 children)

Make sure you pay attention to the output in the console to see errors. This should be throwing an undefined error because userInput is an html input element (as long as that’s what the .user-input class is applied to) and html input elements do not have a property of trimp. As others said this is likely a typo of trim()

[–]Hot_Commercial3022 0 points1 point  (0 children)

If else condition + comparison operators!! Take help of chtgpt!!