Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Arrays
//Arrays //arrays are variables var colors = ['red', 'blue', 'green']; print(colors); //starts at 0 print(colors[0]); print(colors[1]); print(colors[2]); //You can also use: var colors2 = new Array('red', 'orange', 'yellow'); print(colors2); // You can add more values later colors[3] = ('purple'); print(colors[3]); //but a better way if you dont know how many values the variable has is with ".push" colors.push('pink'); // this will add another value print(colors[4]); //Numbers- dont use ' var numbers = [5, 77, 18, 16, 24]; print(numbers); print(numbers[0]); print(numbers[1]); print(numbers[0] + numbers[2]); // dont woory- you can add strings to numbers numbers.push('string'); print(numbers[5]); //you can see how many values an array has with ".length". This is a property. print(numbers.length); //function- sort print(numbers.sort()); // it seems to sort the first number of each value first, so 5 is after 16 and 24, and 18 is after 16 because 8>6
run
|
edit
|
history
|
help
0
JS exam part 2 - Moms
2k Dreamin
binary
Javascript reverse string, one index
JS exam part 2 - MonthCrypto
Константа круга
ArraY_ROW addition
LazyListJS
Lovedek_ellovesi_tavolsag_kalkulator
Time Waister