Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #26866

Re: multi dim array

From "Christoph M. Becker" <cmbecker69@arcor.de>
Newsgroups comp.lang.javascript
Subject Re: multi dim array
Date 2015-02-18 01:47 +0100
Organization solani.org
Message-ID <mc0nfq$ld8$1@solani.org> (permalink)
References <1bf955cc-1954-4144-a78c-930c8c3d5e5e@googlegroups.com>

Show all headers | View raw


JRough wrote:

> I'm trying to get this output from a  ;
> 1-1
> 1-3
> 1-5
> 3-3
> 3-5
> 5-5
> Would this be a 4 dimensional array? 

Why should that be a four dimensional array?  If at all, it might be
some representation of a two dimensional array.  Note, however, that
ECMAScript implementations (usually) have only one dimensional arrays.

> Otherwise does this algorithm make sense?

Which algorithm?

> I had a test interview question and maybe I didn't understand the question. I was trying to do it anyway.  This gets a syntax error.

Well, you've screwed up. :)

> var a = [1,3,5];
> for (var i=0;i< a.length; i++;){
>    for( var j=9;j< a.length; j++){

You're trying to run a loop from 9 to 2 with a step (increment) of 1.
Surely, that'll never execute the loop body.

>    	var myarr=[];
>     push.myarr[i,j] ;

Most likely there is no `push` object, so you can't access one of its
properties (`push.myarr`); probably you confused that with `myarr.push`.
 Anyhow, [i,j] is not a valid property accessor, but rather a syntax error.

> console.log(myarr[i,j]);

Same here.

>   };
> };

I suggest you learn about the syntax and semantics of ECMAScript, and
make use of one of the many "interactive shells" widely available
nowadays, such as the script consoles of contemporary browsers.

-- 
Christoph M. Becker

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

multi dim array JRough <janis.rough@gmail.com> - 2015-02-17 14:48 -0800
  Re: multi dim array "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-02-18 01:47 +0100
  Re: multi dim array Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2015-02-18 01:22 -0200
  Re: multi dim array Denis McMahon <denismfmcmahon@gmail.com> - 2015-02-18 14:12 +0000
  Re: multi dim array "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-02-18 17:55 +0100

csiph-web