Arrays in JavaScript

Words
95
Reading
1 min
Listen
Play
7y

Today I got introduced to Arrays in JavaScript. Here is the tutorial that I used:
https://www.learn-js.org/en/Arrays

In the exercise I had to define an array with the following three variables:

  1. A string which has the value of "What is the meaning of life?"
  2. A number which has a value of 42
  3. A boolean which has a value of true

After much trial and error I found this solution:

var myArray = ["What is the meaning of life?", 42, true];
console.log(myArray[0]);
console.log(myArray[1]);
console.log(myArray[2]);

Tomorrow I will pick up a book "JavaScript for Kids: A Playful Introduction to Programming", 2014 by Nick Morgan which I ordered from Amazon. Thank you alexbiojs@alexbiojs for recommending it!

Arrays in JavaScript | Ecency