I have a rather strange error occurring in my JS application on a random basis. Basically, a script cannot exactly compare two lines. More specifically, at times it is not visible that two identical lines are identical: ('blah' == 'blah') returns false .
The funny thing is that in another attempt, the same two lines can be recognized identical (the operator returns true ). I never managed to figure out a pattern. Ive also tried using === instead of == ; It did not help.
I could not think of a better way to demonstrate and prove this ridiculous mistake, except by recording a screencast. So here it is: http://www.screenr.com/klOs . I continue to give the correct answers to each quiz in this video, but towards the end you will find out how my answers to “Japan and Taiwan” will be considered “wrong”; the console will also show the given response line, the correct response line and the result of their comparison ( false ? !!).
So what could be causing this odd behavior and how can I fix it?
You can see the code using the comparison instruction in screencast. "Params.givenAnswer comes directly from the button's text label:
//*** Options for answering the card quiz quizOptions = new Ext.Panel({ id: 'quizOptions', […………] listeners: { el: { scope: this, tap: this.checkAnswer } } }); checkAnswer: function(container, element) { // Get the text value of the button clicked var answer = Ext.fly(element).dom.innerText; Ext.dispatch({ controller: 'Practice', action: 'checkAnswer', givenAnswer: answer }); },
UPDATE Thanks @JAAulde and @Mike! Ive tried to include quotes and type var in the log, and I got this result:

Now it’s clear why string comparisons fail: the first line seems to have an extra line break. It’s still very strange, since it didn’t look like an empty new line in the previous protocol, and, most importantly, it appears there by accident (note how “Taiwan was adopted this time without any problems”).
Ive included a simple line delete rule for response lines, and now everything works fine. Thanks everyone!