Skip to content

natedev-launchcode/practice-common-array-methods-Nathan-A

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Practice: Common Array Methods

A small Node.js practice exercise covering the most common JavaScript array methods. Only the following methods are used: push, pop, unshift, shift, includes, indexOf, lastIndexOf, concat, slice, splice, sort, reverse.

What it does

The script walks through five focused tasks:

  1. Adding and Removing Elementspush, shift, unshift to mutate a fruits array.
  2. Query and Accessincludes, indexOf, lastIndexOf to inspect a colors array.
  3. Combining Arraysconcat and push to merge two team arrays.
  4. Extracting and Splicingslice to extract a subrange (non-mutating) and splice to replace elements (mutating).
  5. Sorting and Reversingsort((a, b) => a - b) followed by reverse() for descending order.

How to run

Prerequisites: Node.js installed.

# from the project root
node index.js

Expected output:

Task 1: [ 'grape', 'banana', 'cherry', 'orange' ]
Task 2: [ true, 1, 3 ]
Task 3: [ 'Alice', 'Bob', 'Charlie', 'Diana', 'Eve' ]
Task 4 middleNumbers: [ 20, 30 ]
Task 4 numbers: [ 10, 20, 30, 60, 70 ]
Task 5: [ 95, 85, 75, 70, 60 ]

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors