Manipulating arrays in JavaScript
(Edited)
Today I learned about manipulating arrays in JavaScript. The exercise was taken from this site:
https://www.learn-js.org/en/Manipulating_Arrays
In the exercise I had to manipulate the array called myArray
and do the following:
- Push the number 42 to the end of the array
- Shift a variable from the beginning of the array
After much trial and error I came up with this solution:
var myArray = [true, "What is the meaning of life?"];
myArray.push(42);
myArray.shift();
console.log(myArray[0]);
console.log(myArray[1]);
0
0
0.000
Thank you so much for participating in the Partiko Delegation Plan Round 1! We really appreciate your support! As part of the delegation benefits, we just gave you a 3.00% upvote! Together, let’s change the world!