where this array concept can be used? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

where this array concept can be used?

20th Aug 2016, 7:39 PM
Samkitkumar Jain
Samkitkumar Jain - avatar
4 Answers
+ 3
Many many applications.. Here are some fun examples.. Var pagecontent=["content including dom or text or html or functions for home", "content for about","content for contact/location"]; function updatecont(n){ document.content.innerHtml = pagecontent[n]; } Then for a menu you could do... <a href="#content" onclick="updatecont(0)">Home</a> and so on... Or... Say u want a simple text to 1337 speak converter.. function simple1337(str){ var f = ["o","i","z","e","a","s","","t","b","g"]; var leetstr =""; for(var i=0; i < str.length;i++){ var t = f.indexOf(str[i]); if(t >= 0){ leetstr += String.fromCharCode(t+0x30); } else { leetstr += str[i]; } } return leetstr; } document.write(simple1337("oh.. You know.. Maybe for kewl thingz like this..")); Which will output... 0h... Y0u kn0w... M4y83 f0r k3wl 7h1n92 l1k3 7h15..
23rd Aug 2016, 1:50 PM
fjlj
+ 1
Storing data, applying functions to all of its elements, sorting the elements in regards to one of their properties, building more complex data structures... Also, strings are arrays of characters. Long story short, this is the most basic data structure and you will encounter it a lot.
21st Aug 2016, 5:56 AM
Zen
Zen - avatar
0
When storing alot of data. Also useful when making games such as a chess game.
20th Aug 2016, 7:49 PM
Oscar
Oscar - avatar
0
store a collection of data
6th Oct 2016, 8:03 PM
Chaitanya sudhakar
Chaitanya sudhakar - avatar