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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:56:47+00:00 2026-05-25T14:56:47+00:00

I need to format an array from a list of values. Currently I have

  • 0

I need to format an array from a list of values.

Currently I have the following hard-coded points:

points = [
{x: 20, y: 112},
{x: 23, y: 101},
{x: 51, y: 89},
{x: 63, y: 89},
{x: 84, y: 129},
{x: 64, y: 153},
{x: 45, y: 151},
{x: 38, y: 140},
{x: 28, y: 150},
{x: 10, y: 144},
{x: 0, y: 130},
{x: 10, y: 114}
];

The resulting array is to be passed to a function.

I now need to pass another array to the same function but I cannot hard-coded them as above. Instead, I am using a JS framework to grab the points dynamically using, for example, $(#container).get(‘points’);

How do I convert the new array so that it is formatted similarly to the x: | y: structure as above?

points="20,112, 23,101, 51,89, 63,89, 84,129, 64,153, 45,151, 38,140, 28,150, 10,144, 0,130, 10,114"

I found the following in MooTools:

Array.each([1, 2, 3], function(number, index)
{
    alert('x:' + number + ', y: ' + index);
});

…but somehow that doesn’t seem like the correct way to do this.

Can I get a little guidance please?

  • 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-25T14:56:48+00:00Added an answer on May 25, 2026 at 2:56 pm

    You can split [docs] the string and iterate over it, taking two values in each iteration:

    var parts = points.split(',');
    var pointsArray = [];
    
    for(var i = 0, l = parts.length; i < l; i += 2) {
        pointsArray.push({x: +parts[i], y: +parts[i+1]});
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

using jquery I need to retrieve an array from table cells, format the data
i am trying to return a list of users whose accounts have expired from
I have an XML file with the following format: <?xml version=1.0 encoding=UTF-8?> <Items> <Item
I have a Activity that pulls an Array from the previous Activity . I
I'm using a foreach loop to create an array from database values like so:
I have a requirement where i need to loop through JSON Format data and
So i need this format json and i have this so far { query:'Li',
I have an URL like this: http://site.com/images/961b7d0e50f0462a8828d31bf0874a71/lightbox I need to string.format replace the GUID
I need to format an integer representation of bytes into something friendly, and I'm
I need to format a decimal value into a string where I always display

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.