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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:11:42+00:00 2026-05-27T10:11:42+00:00

Okay, very simple: there is an array containing 3 objects. Each object has a

  • 0

Okay, very simple: there is an array containing 3 objects. Each object has a unique property called “ID” with values of either 1, 2, or 3.

One of the objects gets deleted.

The objective now is to update the ID property of each object corresponding to the new array.length value.

So for example, the object with ID of 2 got deleted. The remaining objects in the array would each have ID values of 1 and 3 respectively.

So the objective is to loop through the array and update the ID properties to 1, and 2 (instead of 1 and 3).

So I guess the question is how to write a loop to update a common property of each element in an array. Thanks.

  • 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-27T10:11:43+00:00Added an answer on May 27, 2026 at 10:11 am

    You can use a for-loop to go through the array, as in walkietokyo’s answer, or you can use a method closure:

    myArray.forEach ( function ( item:*, i:int, arr:Array) : void { item.ID = i; } );
    

    or a while-loop:

    var i:int = -1;
    while (++i < myArray.length) myArray[i].ID = i;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay guys, I'm sure this has a very simple solution but my searches are
Okay, this is (probably) a very simple question, but I am afraid I know
Okay, this is probably very simple but, I have the below checks (not at
Okay, here is a very simple and fundamental question. If I have an application
Okay, the title isn't very clear. Given a byte array (read from a database
Okay, this is just a crazy idea I have. Stack Overflow looks very structured
I just want to play a very simple, straight forward note by giving my
I noticed the WinForms RichTextBox has a ZoomFactor property that I assume is exactly
Okay so my question is this. Say I have a simple C++ code: #include
very simple question: I have admin site in my web project. So, how can

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.