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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:07:07+00:00 2026-05-23T18:07:07+00:00

I have a problem with a task which i am trying to solve. I

  • 0

I have a problem with a task which i am trying to solve.

I have been set a task which most do the following;

1) On each number within the array, print out to screen (in an unordered list) each number’s array value and their associated description.

And the code is to do this task with is as follows;

var numbers = [
  '1',
  '2',
  '3',
  '4',
  '5',
  '6'
],

description = {
  'One': 'Number one',
  'Two': 'Number two',
  'Three': 'Number three',
  'Four': 'Number four',
  'Five': 'Number five',
  'Six': 'Number six'
};

Does anyone have any idea how to solve this using some sort of loop?

If you could also explain to me in comments to tell me whats happening that would be great.

Kind Regards,

B

  • 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-23T18:07:08+00:00Added an answer on May 23, 2026 at 6:07 pm

    You can assign an array of objects, each object containing a description that corresponds to the index value of that object:

    // assign an array of objects
    // numbers[3] for example contains {name: 'Three', description: 'Number three'}
    var numbers = [
      {name: 'Zero',  description: 'Zip!'},
      {name: 'One',   description: 'Number one'},
      {name: 'Two',   description: 'Number two'},
      {name: 'Three', description: 'Number three'},
      {name: 'Four',  description: 'Number four'},
      {name: 'Five',  description: 'Number five'},
      {name: 'Six',   description: 'Number six'}
    ],
    // a results container
    result = [];
    // iterate through the numbers array and push a string
    // string containing index, name and description to
    // result
    for (var i=0;i<numbers.length,i=i+1){
       result.push(i+': name = '+numbers[i].name+
                   ', description = '+numbers[i].description);
    }
    // show the result, joining the result array into a string,
    // separated by a line break '\n'
    alert(result.join('\n'));
    
    /* alerts:
     0: name = Zero, description = Zip!
     1: name = One, description = Number one
     2: name = Two, description = Number two
     3: name = Three, description = Number three
     4: name = Four, description = Number four
     5: name = Five, description = Number five
     6: name = Six, description = Number six
    */
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to solve a classic problem - I have a multi-threaded application which
Here's a problem. Developers have some kind of a task (develop certain feature), which
I have a problem concerned with losing of precision my task is to print
I'm trying to use STL to solve the following problem (I don't want to
Here's a problem I've been trying to solve at work. I'm not a database
I was recently trying to solve some task in Python and I have found
While doing some small regex task I came upon this problem. I have a
I have a task - add round corners to HtmlPanelGrid. Now I am trying
I have a Core Data model in which a Task entity includes an optional
I have now used way too long time, trying to figure out a problem,

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.