Hi,
i tried this:
a=new Array()
for (i=1;i<=3;i++)
{
for (j=1;j<=2;j++)
a[i,j]=i+j
}
for (i=1;i<=3;i++)
{
for (j=1;j<=2;j++)
alert(a[i,j])
}
but i get 4,5,4,5,4,5 while i expect 2,3,3,4,4,5
Thanks
Dave 3 3354
"Dave" <ry**@no.mn> schreef in bericht news:bi**********@reader11.wxs.nl... Hi,
i tried this: a=new Array() for (i=1;i<=3;i++) { for (j=1;j<=2;j++) a[i,j]=i+j }
for (i=1;i<=3;i++) { for (j=1;j<=2;j++) alert(a[i,j]) }
but i get 4,5,4,5,4,5 while i expect 2,3,3,4,4,5
a=[];
for (i=1;i<=3;i++) {
a[i] = [];
for (j=1;j<=2;j++)
a[i][j] = i+j;
}
for (i=1;i<=3;i++) {
for (j=1;j<=2;j++)
alert(a[i][j]);
}
JW
Dave wrote: Hi,
i tried this: a=new Array() for (i=1;i<=3;i++) { for (j=1;j<=2;j++) a[i,j]=i+j }
for (i=1;i<=3;i++) { for (j=1;j<=2;j++) alert(a[i,j]) }
but i get 4,5,4,5,4,5 while i expect 2,3,3,4,4,5
You can only create an array of arrays with JavaScript
var a = new Array();
for (var i = 0; i < 5; i++) {
a[i] = new Array();
for (var j = 0; j < 10; j++) {
a[i][j] = j;
}
}
--
Martin Honnen http://JavaScript.FAQTs.com/ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Ohmu |
last post by:
Hi!
How to pass an (multidimensional)array of something to a function with
reference/pointer?
Can anyone help me with that?
Thanks,
Ohmu
|
by: Tom |
last post by:
Hi,
I am new in programming (and certainly in C++). I want to creat a
five-dimensional array. Two dimensions are numbers and other three are
variable.
One of the variables is an array whose...
|
by: Fabian |
last post by:
I have a three tier nested array, used to define a map for a javascript
game, and can be edited within the web page. Is there a way I can
generate a visible copy of this array that I can then c&p...
|
by: Bangalore |
last post by:
Hi all,
Plz clarify me, on the implementation of two or three dimensional
array using overloaded operator.
Thanks, in advance
Bangalore
|
by: Salman Khilji |
last post by:
After reading all the FAQs, I cannot solve the following problem:
I have a pointer of type double. I am supposed to
1) Allocate memory for it assuming that the pointer will be pointing
to a...
|
by: Leszek |
last post by:
Hi.
Is it possible in javascript to operate on an array without knowing how mamy
elements it has?
What i want to do is sending an array to a script, and this script should
add all values from...
|
by: finerrecliner |
last post by:
hey everyone
i'm trying to make a function that will return the length and width of
a dynamically allocated 2D array.
here's what i came up with to find width:
int findWidth(int** matrix)...
|
by: Miles |
last post by:
Hi all,
Wondering if anyone can help me. If i have an associative array:
$arr = array(
"one" =array(1, 2, 3),
"two" =array(5, 6),
"three" =array(7,8,9,10)
....
"n" =array(p,q,r....)
|
by: dennis.sam |
last post by:
Hi,
Is there away to define a multi-dimensional array with respect to the
number of dimensions the array has? For example, given a user spec of
"a b c d", I want to create a 4 dimensional array...
|
by: Stephen.Schoenberger |
last post by:
I have declared a bunch of arrays and now I need to change the
dimensions on some of the arrays. For instance
int size = 1000;
int array1;
array1 is then filled with some values
now array1...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |