Skip to content

Latest commit

 

History

History
34 lines (22 loc) · 788 Bytes

README.md

File metadata and controls

34 lines (22 loc) · 788 Bytes

JavaScript Shift Method

The goal is to replicate JavaScript's shift() functionality

How will it work?

  1. The shift() method must receive a list
  2. The value of the first index in the list must be removed
  3. The method must return the extracted value

Example

function shift(list) {
    // code
}

let myList = ['dog'. 'banana', 'orange']
const shiftList = shift(myList)

console.log(shiftList)
// return 'dog'

console.log(myList)
// return ['banana', 'orange']

Testing

Create a test to validate the behavior is as expected, you can even start by testing to train TDD.

Contribute

Place the challenge files inside the challenge/your-github-username folder and open a pull request.