Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6827849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:18:49+00:00 2026-05-26T22:18:49+00:00

I’m having a pretty weird bug occurring in my JS application on a random

  • 0

I’m having a pretty weird bug occurring in my JS application on a random basis. Basically, the script fails to accurately compare two strings. More specifically, at times does not see two identical strings as identical: ('blah' == 'blah') returns false.

The funny thing is that on another try, the same two strings may be admitted to be identical (statement returns true). I never managed to figure out the pattern. I’ve also tried to use === instead of ==; this didn’t help.

I couldn’t think of a better way to demonstrate and prove this ridiculous bug other than by recording a screencast. So here it is: http://www.screenr.com/klOs. I keep giving correct answers for each quiz in that video, but closer to the end you will how my answers for ‘Japan’ and ‘Taiwan’ will be regarded as ‘wrong’; the console will also show the given answer string, the correct answer string, and the result of their comparison (false ?!!).

So what could possibly be the reason for this odd behaviour and how do I get around fixing it?

You can see the code with the comparison statement in the screencast. The ‘params.givenAnswer’ comes directly from the button 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 Thank you @JAAulde and @Mike! I’ve tried to include the quotes and the var type in the logging and I got this result:

enter image description here

Now it’s clear why the string comparison fails: there seem to be an extra line break of sorts in the first string. It’s still very weird, since it didn’t not appear as a blank new line in the previous logging, and most importantly, it appears there randomly (notice how ‘Taiwan’ was accepted this time without any problems).

I’ve included a simple line-break removal rule for the answer strings, and now everything seem to be working fine. Thanks a lot everyone!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:18:49+00:00Added an answer on May 26, 2026 at 10:18 pm

    Using === is a strict equality comparison. This means that the data type and the contents are being compared. They both (data and type) must be the same to equal and return true.

    When you switched your strict comparison to == the test should have worked even though the data types were different. It failed however because of the extra blank spaces.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some weird issues with Xcode, and this is pretty much impossible to
We are having an application developed for BlackBerry - a pretty big one only.
This is a very weird bug I'm having. I'm using Modernizer and after a
I'm having a pretty weird problem with one of my rails apps. I think
I'm having a pretty weird problem with PHP and MySQL. I'm doing the following
I am having weird scrolling issues in my pretty simple GridView. Each item in
I am having a very weird error on this block: <script type=text/javascript> var captions
I'm having trouble with classes in haskell. Basically, I have an algorithm (a weird
I'm having a pretty difficult time with my resources within the view pages. The
I'm having a pretty big problem trying to create navigation on my page. If

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.