LEVEL UP with JavaScript! LVL 7

LEVEL UP with JavaScript! LVL 7

In this blog series tutorial, I will be covering some of the basic JavaScript programming concepts.

This is geared toward beginners and anyone looking to refresh their knowledge.

See the Previous Level Here

Level 7 will cover:

  • Store Multiple Values in One Variable Using JavaScript Arrays
  • Nest One Array Within Another Array
  • Access Array Data With Indexes
  • Modify Array Data

Store Multiple Values in One Variable Using JavaScript Arrays

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[3];

// 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[0] = 4;

diceArray[0];

// 4

// Now the 2 in our array is 4

Thank you for reading my blog! This is the seventh of my series on JavaScript so if you would like to read more, please follow!

See the Next Level Here

Support and Buy me a Coffee