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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:06:10+00:00 2026-06-09T19:06:10+00:00

I am an array in following format. I am reading following data from a

  • 0

I am an array in following format. I am reading following data from a file data.json like this

$.getJSON('data/data.json', function (ids) {
            for (var i = 0; i < ids.length; i++) {
                var id = ids[i];
                teams = id;
                $('<li>' + id + '</li>').appendTo(span);

            }
        });

here is data

[
"109 200",
"109 201",
"102 202",
"103 202"
]

So what I want is to copy this array to another lets say c but in following form

[
"109",
"109",
"102",
"103",
"200",
"201",
"202",
"202"
]

How can I do this using javascript or jquery?

  • 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-09T19:06:11+00:00Added an answer on June 9, 2026 at 7:06 pm

    Iterate over the result set, split each element by whitespace, and add the resulting two numbers to two different arrays, each representing one halve, and finally, concatenate the left part with the right part:

    var left = [], 
        right = [];
    for (var i = 0; i < ids.length; i++) {
      var pair = ids[i].split(" ");
      left.push(pair[0]);
      right.push(pair[1]);
    }
    var result = left.concat(right);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am reading some lines from a file in the following format: Identifier String
Given following array: var arr = [undefined, undefined, 2, 5, undefined, undefined]; I'd like
Given the following array of json objects: var items = [ {id:1, parentId:0, name:'item1'},
I have a php query the returns the following JSON format from a table.
I have a php query the returns the following JSON format from a table.
I have an array in the following format: var markers = [ ['Title', 15.102253,
Official PHP documentation states that filter_var_array() supports array filtering in the following format: $data
How would I create an array that will return data in the following format
I have an array in the following format. $data = array( 1=>array('img'=>'1.png','title'=>'title1','desc'=>'desc1'), 2=>array('img'=>'2.png','title'=>'title2','desc'=>'desc2'), 1=>array('img'=>'3.png','title'=>'title3','desc'=>'desc3'),
Background I basically have an array, this array has the following format Array (

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.