https://github.com/jswesterfield/planets-js
planets-array.js. Some practice with array methods.
https://github.com/jswesterfield/planets-js
Last synced: 6 months ago
JSON representation
planets-array.js. Some practice with array methods.
- Host: GitHub
- URL: https://github.com/jswesterfield/planets-js
- Owner: JSWesterfield
- Created: 2017-01-07T07:48:00.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-01-07T08:19:19.000Z (about 9 years ago)
- Last Synced: 2025-01-07T13:12:09.666Z (about 1 year ago)
- Language: JavaScript
- Size: 9.77 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# planets-js
planets-array.js. Some practice with array methods.

**Steps in js**
1. Created an array of planets
2. Created a function for logging the planets array
3. _.unshift method_. Added "The Sun" to the beginning of the planets array
4. _.push method_. Added "Pluto" to the end of the planets array
5. _.shift method_. Removed "The Sun" from the beginning of the planets array.
6. _.pop method_. Removed "Pluto" from the end of the planets array.
7. _.indexOf method_. Found and logged the index of "Venus" in the planets array.
8. _.splice method(remove)_. Created an index of pre-sliced element, then used the splice method to remove the planet after "Venus".
9. _.splice method(add)_. Used splice to add back the planet after "Venus".
10. _.reverse method_. Reversed the order of the planets array.
11. _.sort method_. sorted the planets array.