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 9159787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:34:42+00:00 2026-06-17T13:34:42+00:00

I have some JavaScript code that I can’t get to work. I’ve tried moving

  • 0

I have some JavaScript code that I can’t get to work. I’ve tried moving some stuff around, and changing up some keywords, but nothing has worked so far. I’ll let you guys take a crack at it.

This is the javascript file:

    var GAME = {

  /////////////////////////////
  // GAME PROPERTIES         //
  /////////////////////////////

  /* LAYOUT PROPERTIES */
  ROWS: 3,
  COLS: 3,
  CELLS: {
    TOTAL: ROWS * COLS,
    CELL_SIZE: 25,
  },

  /////////////////////////////
  // GAME METHODS            //
  /////////////////////////////

  display: function() {

    alert( "ROWS: " + ROWS );
  }

};

On a separate HTML web page, I am using the following code:

<script type="text/javascript">
<!--
GAME.display();
//-->
</script>

I’ve run the code on firebug and I’ve gotten the following error:

TypeError: GAME is undefined

I’ve tried, but I can’t get the error to go away. Help!

COMPLETE HTML PROVIDED:

<!doctype html>
<html>
  <head>

    <meta charset="utf-8">
    <title>JavaScript Canvas | Tic-Tac-Toe</title>

    <style type="text/css">
    #canvas01 {
      border: 1px solid #000;
    }
    </style>


    <!-- JQUERY -->

  </head>
<body>


<div id="canvas01"></div>

<script type="text/javascript" src="http://d3lp1msu2r81bx.cloudfront.net/kjs/js/lib/kinetic-v4.3.1.min.js"></script>

<script type="text/javascript" src="game/core.js"></script>

<script type="text/javascript">

GAME.display();


</script>

</body>
</html>
  • 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-17T13:34:43+00:00Added an answer on June 17, 2026 at 1:34 pm

    You can’t define a property of an object based on another property inside the same object at the point of instantiation. Right now, the culprit that is preventing GAME from being defined is the assignment of TOTAL (your JS runtime will throw a TypeError saying ROWS is undefined since it appears first). You should always use local variables to define the properties of your object, because who knows when your game will need different requirements? Also, take note that you should use this to point to the context of the object for when you want to display the number of rows. You would have to do something like this:

    var rows = 3, cols = 3, cellSize = 25;
    
    var GAME = {
    
    
    
    /////////////////////////////
      // GAME PROPERTIES         //
      /////////////////////////////
    
      /* LAYOUT PROPERTIES */
      ROWS: rows,
      COLS: cols,
      CELLS: {
        TOTAL: rows * cols,
        CELL_SIZE: cellSize,
      },
    
      /////////////////////////////
      // GAME METHODS            //
      /////////////////////////////
    
      display: function() {
        alert( "ROWS: " + this.ROWS );
      }
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some JavaScript code that does some stuff, but at some point I
I have some javascript code that generates additional input fields. So, I can know
I have some Javascript code that will programmatically register an COM interop assembly by
I have some JavaScript code that works in IE containing the following: myElement.innerText =
I have some javascript code that creates an img tag with a mouseover callback,
I have some Javascript code that creates 2 arrays: One for Product Category and
I have some javascript code that saves a cookie. However, if after saving the
i have some javascript roll over code that works fine in firefox but when
I have some javascript and c# code inside one of my views that is
I have some code that dynamically creates a new button through JavaScript that when

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.