/    Sign up×
Community /Pin to ProfileBookmark

two-dimentional arrays

Why can’t I assign: myArray[1][0] = “de beer”;?

Error says:
“1” is null or not an object…

function showArr() {
var myArray = Array(Array());
myArray[0][0] = “michelle”;
myArray[1][0] = “de beer”;
alert(myArray[1][0]);
}

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@gil_davisMar 25.2003 — function showArr() {
var myArray = new Array();
myArray[0] = new Array("michelle", "de beer");
alert(myArray[0][0]); // michelle
alert(myArray[0][1]); // de beer
}
Copy linkTweet thisAlerts:
@michelleauthorMar 25.2003 — 
var myArray = Array(Array());

only created the zeroeth element as 2-dimensional.

QUOTE]

So, how do I create a 2-dimensional array that can carry the values:

myArray[0][1] = "michelle";

myArray[1][1] = "de beer";

etc...


// Michelle
×

Success!

Help @michelle spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...