code won't return value for some reason
I am making Hangman. I tested it a specific code but it didn't work. So I debugged it. I don't know why it always returns 'undefined'. This is the code ---- function confirm() { var inp = $('textarea').val() var c = null var x = 0 for(; x <= word.length; x++) { if (!c) { c = (inp == word[x]) } } if (c === true) { display[x] == word[x] // piece of code that returns 'undefined' alert(display[x]) writeOnScreen() document.getElementById('right').play() } else { attempts-=1 $('.ats').text(attempts) document.getElementById('wrong').play() drawVisual() } } ----- FYI there is a variable named 'display'. It's value is '??????'. I defined it like this l var display = '??????' l. So now you won't say it returns undefined because there is no variable display. If you know why, please reply why it keeps returning null. If you know how, you can fix the code.