Hi im abit new with Js i created an easy timer in Js and now i wanna try something new.
Well i tried a few stuffs the ni thought of variables in arrays... i know that u can but normal "words" in an array but how do u do with variables?
var mycars = new Array();
mycars[0] = "Saab";
mycars[1] = "Volvo";
mycars[2] = "BMW";
Here i use normal words..
Can someone please tell me how i can input variables into the array so that the variable input shows instead of the variables name. =)
Variables in array.
Moderator: General Moderators
Re: Variables in array.
Assuming you have the variables set ahead of time, you can just set the values in the array to the variable. For example,
Code: Select all
var mycars = new Array();
var saab = 'saab';
var volvo = 'volvo';
var bmw = 'bmw';
mycars[0] = saab;
mycars[1] = volvo;
mycars[2] = bmw;
Re: Variables in array.
hmm i seem to have something wrong with mine. That didnt work when i tried it. I=ll try it again on another editor and see if i can manage it.