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

  • Home
  • SEARCH
  • 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 8622573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:05:27+00:00 2026-06-12T07:05:27+00:00

I am using an approach described in detail at Dictionary Lookups in Javascript (see

  • 0

I am using an approach described in detail at Dictionary Lookups in Javascript (see the section”A Client-Side Solution”) to create an object that contains a property for each word in the scrabble dictionary.

var dict = {};

//ajax call to read dictionary.txt file
$.get("dictionary.txt", parseResults);


function parseResults(txt) {
var words = txt.split( "\n");

  for (var i=0; i < words.length; i++){
      dict[ words[i] ] = true;
  }

  console.log(dict.AAH);
  console.log(dict);

  if (dict.AAH == true) {
     console.log('dict.AAH is true!');
  }


}

(updated code to use an earlier answer from Phil)

I can’t figure out why dict.AAH is returning undefined, but the dict object looks fine in the console. Screenshots from Firebug below.

Console:

console

Drilled down into “Object { }”

Object

How can I check a given word (“AAH”, in this case) and have it return true if it is a property in the dict object defined as true?

  • Live example
  • Code on Github
  • 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-06-12T07:05:29+00:00Added an answer on June 12, 2026 at 7:05 am

    The problem isn’t your code. You have invisible characters in your words, which you fail to clean up.

    You can verify this by using this as your results parser

    function parseResults(txt) {
      // clean the words when we split the txt
      var words = txt.split("\n")
                     .map($.trim)
                     .splice(0,3); // Keep only 3 first ones
    
      if(btoa(words[2]) !== btoa('AAH')){ // Compare in Base64
        console.log('YOU HAVE HIDDEN CHARS!');
      }
    
    }
    

    And you can fix it by whitelisting your characters.

    function parseResults(txt) {
      // clean the words when we split the txt
      var words = txt.split("\n").map(function(el){
        return el.match(/[a-zA-Z0-9]/g).join('');
      });
    
      for (var i=0; i < words.length; i++){
          dict[ words[i] ] = true;
      }
    
      console.log(dict.AAH);
      console.log(dict);
    
      if (dict.AAH == true) {
         console.log('dict.AAH is true!');
      }
    }
    

    I would recommend cleaning it up on the server side since running regex on every element in an array as large as seen in your live site might cause performance issues.

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

Sidebar

Related Questions

I was reading today about OOCSS which says by using that approach have 2
I've been using the following approach to create components and return values from Swing
Some time ago I adapted my Xcode workflow using the tab-approach as described by
I am using the approach described in this stackoverflow posting to retrieve values from
We are using the approach described here to log our webservice errors with Elmah.
I'm using an approach for this thread in order to make gallery change one
I am using CodeFirst approach and struck with an issue where I need to
I'm using this approach to store data in a global array hosting an http
So, I'm using this approach to be able to drag an image: Dragging an
I'm using a naive approach to this problem, I'm putting the words in a

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.