www.webdeveloper.com
Results 1 to 3 of 3

Thread: Building 2d array issue

  1. #1
    Join Date
    Jun 2012
    Posts
    1

    Building 2d array issue

    Hi all,

    I am working on a javascript quiz for finding musical notation errors. The quiz enables users to click on an area of a canvas, and if that area contains an error, a rectangle (pre-defined) is drawn. This code relies on constructing 2d arrays. I have 3 sets of 2d arrays defined, but these arrays need to be deconstructed. What I am trying to do is call a function that creates a new array and fills it with all of the elements of my 2d arrays. What I have so far is:

    function selectArray(array){
    newarray = new Array;
    for (var i = 0; i < array.length; i++){
    for (var t = 0; t < array[i].length; t++){
    newarray[i][t] = array[i][t];
    alert(newarray);
    }
    alert(newarray)
    }
    }

    I have tried this and several variations of this and nothing works. Any ideas?
    Thank you very much!

  2. #2
    Join Date
    Jan 2007
    Location
    Wisconsin
    Posts
    2,120
    Confused.

    You're just trying to clone an array?
    Jon Wire

    thepointless.com | rounded corner generator

    I agree with Apple. Flash is just terrible.

    Use CODE tags!

  3. #3
    Join Date
    Oct 2010
    Location
    Versailles, France
    Posts
    1,268
    See for example this tutorials
    Code:
    newarray = new Array();
    Then it's often better to choose very different variable names than reserved words...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles