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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:08:55+00:00 2026-05-23T17:08:55+00:00

I start out with an array of strings where each element of the array

  • 0

I start out with an array of strings where each element of the array is separated by “//”. e.g. temp[0] = {"sky//hi//pi"} , temp[1] = {"fish//steak//carrot"}. Now my code looks like this:

for (var i = 0; i < temp.length ;i++)
{
window.data_arrays = Array(2);
window.data_arrays[i] = temp[i].split("//");
}

What I’m trying to do is to make data_arrays into a 2 dimensional array…so for the example it would be like temp[0][0] = "sky", temp[0][1] = "hi", temp[1][0] = "fish".

However the code doesn’t work. Can someone please help me out?
Thanks. (reason why I’m assigning it to window is because I need to access this variable in another file later)

  • 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-23T17:08:56+00:00Added an answer on May 23, 2026 at 5:08 pm

    Assuming your temp array is correct, you have to initialize the array before the loop:

    window.data_arrays = [];
    for (var i = 0; i < temp.length; i++) {
         window.data_arrays[i] = temp[i].split("//");
    }
    

    Otherwise you overwrite it on every iteration and it will only contain the values of the last iteration.

    DEMO

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

Sidebar

Related Questions

I'll start out by giving you the code I'm working on so that you
Let me start out by saying that I'm not a JavaScript developer so this
I'm trying to start out with LinqtoXml. I have added (I think) the right
What is a strong iPhone framework to start out developing with, besides the SDK
Often when beginning a new project, I start out with what I believe to
I'm working on early designs for an application that needs to start out small
Need some help assigning a mouseover event to display some icons that start out
I've used Process.Start to shell out and call 7zip to archive stuff I've also
When trying to start my JUnit-Test out of Eclipse, I get a ClassNotFoundException. When
I frequently start with a simple console application to try out an idea, then

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.