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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:49:22+00:00 2026-05-29T11:49:22+00:00

Here is some sample code of what I am trying to achieve: pingpong =

  • 0

Here is some sample code of what I am trying to achieve:

pingpong = {
    paddleA: {
        speed: 5,
    },
    paddleB: {
        speed: 6,
    },
    paddleAI: {
        AI1: "paddleA",
        AI2: "paddleB"
    }
}

paddleAI = pingpong.paddleAI;
paddleA = pingpong.paddleA;
paddleB = pingpong.paddleB;

for (paddle in paddleAI) {
    document.write(paddleAI[paddle].speed);
}

When I run this code, it returns “undefined”

I am trying to use the text values in paddleAI as which paddle’s speed I want to access.

How would I get that code to return the speed values of paddleA and paddleB?

Note:
This is only demonstration resembling my actual code, therefore I don’t have much room to dramatically restructure how I am storing and accessing my values.

  • 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-29T11:49:25+00:00Added an answer on May 29, 2026 at 11:49 am

    This is probably what you are after…

    Using the contents of pingpong.paddleAI to tell you what paddles are available…

    Your problem is that you were using paddle in the loop expecting the paddle name, when in fact you were getting the property name ( ex… AI1)

    https://stackoverflow.com/a/5263872/555384

    for (paddle in paddleAI) {
        document.write(pingpong[paddleAI[paddle]].speed);
    }
    

    Although this seems like really bad way to do it…

    Also, your trailing commas will make IE throw fits… remove the last comma in a object/array literal declaration

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

Sidebar

Related Questions

Here's some sample code to explain what I'm trying to do: <div id=list_subpanel_contacts> <table>
I got some sample code from the net here: http://www.javadb.com/sending-a-post-request-with-parameters-from-a-java-class That works fine. It
Here's a mockup: A mockup http://img.skitch.com/20090228-mqdj17xijycc98spf181a8q6q7.jpg I have been trying to find some sample
Here is some simple code: DIR* pd = opendir(xxxx); struct dirent *cur; while (cur
I've got a quite strange problem here. I'm calling some simple code via Ajax.Updater:
here is some sample javascript: SomeObjectType = function() { } SomeObjectType.prototype = { field1:
OK so here is some logic thinking... What I am trying to do is
I have some code where i am trying to throw a custom exception in
Here is some simple Perl to count the number of times a value occurs
This is similar to (but different from) this question . Here is some simple

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.