Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
array indexing, I'm confused
Old 06-15-2009, 02:36 PM array indexing, I'm confused
Average Talker

Posts: 21
Trades: 0
The following code gives me an unexpected result. I thought I understood array indexing. Guess not!
Code:
<script language="javascript">
fooey=[]; // create array named "fooey"
fooey[0]="3";
fooey[1]="adams";
fooey[2]="arnold";
alert(fooey[0]); //testing with alerts
alert(fooey[1]);
alert(fooey[2]);
members=[]; // create  array named "members"
for (i=1;i<=2;i++){ members=fooey[i]}; // load each name found in "fooey" into "members"
alert(members[1]); // result is an "r". expected "adams" ???
</script>
What am I doing wrong?
jimandy is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-15-2009, 03:53 PM Re: array indexing, I'm confused
Average Talker

Posts: 21
Trades: 0
Aha. I found my problem...

Code:
for (i=1;i<=2;i++){ members[i]=fooey[i]};// corrected line
jimandy is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to array indexing, I'm confused
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.09206 seconds with 12 queries