DEV Community

Cover image for LEVEL UP with JavaScript! LVL 7
DevCronin
DevCronin

Posted on

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

Enter fullscreen mode Exit fullscreen mode

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

Enter fullscreen mode Exit fullscreen mode

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

Enter fullscreen mode Exit fullscreen mode

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

Enter fullscreen mode Exit fullscreen mode

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

Top comments (5)

Collapse
 
peppeg85 profile image
peppeg85

sorry but....where is the level UP

Collapse
 
devcronin profile image
DevCronin

*geared toward beginners

Collapse
 
peppeg85 profile image
peppeg85

ok, sorry, i read level up and thinked it was an advanced level post

Thread Thread
 
devcronin profile image
DevCronin

Its okay, I am still a beginner myself.

Collapse
 
apassiondev profile image
Andrey Ho

I wish beginners would be given more helpful information. It's even impractical in every aspect.