-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplanets-array.js
More file actions
41 lines (38 loc) · 1.14 KB
/
planets-array.js
File metadata and controls
41 lines (38 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
(function(){
"use strict";
var planets = [
'Mercury',
'Venus',
'Earth',
'Mars',
'Jupiter',
'Saturn',
'Uranus',
'Neptune'
];
/**
* TODO:
* Read each console log below, and write some javascript code to perform
* the step that it describes
*/
planets.unshift('The Sun');
console.log('Adding "The Sun" to the beginning of the planets array.');
console.log(planets);
planets.push('Pluto');
console.log('Adding "Pluto" to the end of the planets array.');
console.log(planets);
planets.shift();
console.log('Removing "The Sun" from the beginning of the planets array.');
console.log(planets);
planets.pop();
console.log('Removing "Pluto" from the end of the planets array.');
console.log(planets);
console.log('Finding and logging the index of "Earth" in the planets array.');
console.log(planets.indexOf('Earth'));
console.log("Reversing the order of the planets array.");
console.log(planets);
planets.reverse();
console.log("Sorting the planets array.");
console.log(planets);
planets.sort();
})();