+2 william appiah-dankwah · June 10, 2014
i have made an array witch i want to try and use other statements i have learnt to finish of the code, hears my code what can i add to it to make it more interesting 

var gold = new Array();

gold[0] = "goddfellaz";
gold[1] = "sk vibemakers"
gold[2] = "heartless crew"
gold[3] = "rolldeep"
gold[4] = "wolfpack"
gold[5] = "payasyougo"

Post a Reply


- page 4
Oldest  Newest  Rating
0 michael walker · March 30, 2015
event simpler way to display items from an array would be
var ArrayName = new Array("value1","value2"); - 

var printArray = ArrayName.join(" - ");  - note: .join("[can be any separator for the output you want]") default = ,


value1 - value2
0 william appiah-dankwah · March 26, 2015
hay look lima i don't know what your saying that but i asked for help with an array
0 william appiah-dankwah · March 26, 2015

var List = new Array() 

 List[0] = pic/photo-1.JPG;
 List[1] = pic/photo-2.JPG;
 List[2] = pic/photo-3.JPG;


back with an array question why can't i get an image from a file for an array like how i have written the code?

0 Hope Lasr · June 12, 2014
@william appiah-dankwah 

I think you really need to learn some JavaScript basics, it really would help you a lot, I see you are saying that condole.log() does not work, did you try CTRL(control Key) + F12 or FN + F12 depending on your keyboard, then navigate to the  "Console" Tab of your browser's Developer tools? I think that would help.

Please understand that Console.log() is more like your document.write() but the difference is that document.write() will write the output to the page(document) that you are viewing whereas Console.log() will write on the Browsers console. 

Hope that Helps.
+1 Ethan Fraser · June 12, 2014
The poster above has posted something that I don't even understand. I believe that's somewhat throwing a toddler in the deep end of a pool and relying entirely on his floaties. I advise you learn the basics of JavaScript, I know that knowing Java helped me but even that didn't prepare me for something like:

var arrayName = ["String 1", "String 2", "String 3"];

for(var x in arrayName) {

That would loop through the array in the same way as I demonstrated in my above post. The difference is simply the way the for loop is made. Each language has it's own quirks, processes and most importantly, functions. Make sure that you learn that language properly, don't just dive into the heavier stuff. It might take longer but it's safer.
+1 Declan Hester · June 11, 2014
When working with arrays most (if not all) of the time, your array will start at 0 and not one. So when we know we have 5 values in front of us, we count it as 1, 2, 3, 4, 5 -- the computer however, counts it as 0, 1, 2, 3, 4. arrayname.length however is a method that returns the count of the variables in the array, starting at 1 and not 0, so it would return a value of 5 because we have 5 values in the array.

Because the loop posted is counting from 0 (i=0) we want to use the same counting scheme as the computer. If the loop's termination condition was i=arrayname.length, we would run in to an Out of Bounds error, because the program we're writing would look for a 6th value which doesn't exist. That's why if our counter variable starts at 0, our termination condition is always < the length of the array.

That's where the poster above you got < arrayname.length from.

As for console.log will work for you if you're using a debugging tool like FireBug for Firefox or the inbuilt debugger for Chrome (if you're using Chrome, all you need to do is right click anywhere on the page, and then click on "Inspect Element". In the window that appears at the bottom of the screen, click on the Console tab. Anything console.log outputs can be found there.)
0 william appiah-dankwah · June 11, 2014
Console.log does not work I have tried document.write and it prints out the code not sure we're you get < array.length and console.log from
-5 Ethan Fraser · June 11, 2014

var arrayName = new Array();

arrayName[0] = "String 1";
arrayName[1] = "String 2";
arrayName[2] = "String 3";
arrayName[3] = "String 4";
arrayName[4] = "String 5";

for (var i = 0; i < arrayName.length; i++) {


var arrayName = ["String 1", "String 1", "String 1", "String 1", "String 1"];

for (var i = 0; i < arrayName.length; i++) {

Both can be used to display the contents of an array.
0 william appiah-dankwah · June 10, 2014
Just to display the strings nothting technical I learning javascript I like to try a loop
0 Ethan Fraser · June 10, 2014
I'm sorry but again, you need to be more specific. Array can be used in so many ways, what are you using this array for?



A scripting language that is added to standard HTML to create interactive effects, apps, games for the browser.