This is geared toward beginners and anyone looking to refresh their knowledge.
See the Previous Level Here
Level 7 will cover:
- Nest One Array Within Another Array
- Access Array Data With Indexes
- Modify Array Data
Multiple values can be stored together by enclosing them with brackets . These can be any combination of strings and/or numbers.
let myArr = ["Natural", 20];
Nest One Array Within Another Array
Nesting arrays within another array is also possible by using brackets inside of brackets. This is referred to as multi-dimensional array.
let multiDimensionalArray = [ ["Hit points", 30], ["Damage", 15] ];
Access Array Data With Indexes
Indexes are a way to reference and then access data inside of an array. They use brackets and specify an entry in an array. Arrays use Zero-based indexing (starts the count from zero).
let diceArray = [2,5,6,4,1,1]; diceArray; // 4
Modify Array Data
The entries of arrays are able to be changed, and this is referred to as mutable.
let diceArray = [2,10,8,7]; diceArray = 4; diceArray; // 4 // Now the 2 in our array is 4