How to check answers to questions?

I have an exercise of Fill in the Blanks in which clicking the word from options div moves it into the first answer div and so on. However, the code of checking answers in which the background of right answers divs turn green is not working. Please help me solve the problem. The code I am having problem with is:

 if (guess == correct) {

     $('.output').css('background', 'green');


The link of jsfiddle is: https: //

That’s happening because guess is " Might " but correct is “Might”

Why does guess have extra spacing? That’s because the answers on the page have spaces around the word.

I recommend that you replace innerHTML for textContent (which gets the visible text instead) and trim the result.

         // var add =;
         var add =;

It worked, thanks a lot, sir.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.