Christoph M. Becker
2/18/2015 12:48:00 AM
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