Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions arrays/push.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#push

The push method add one or more elements to the end of the original array and returns the new length of the array.
It mutates the original array.

```javascript
let arr = [45, 96, 73, 58, 23]

// arr: [45, 96, 73, 58, 23, 10]
// Result: len = 6
let len = arr.push(10)
```

{% exercise %}
Use the push method to insert 23 at the end of the array RMS and calculate new length of RMS.
{% initial %}
let RMS = [ 100, 20, 55, 87, 91]
let len =
{% solution %}
let RMS = [ 100, 20, 55, 87, 91]
let len = RMS.push(23);
{% validation %}
assert (len === 6)
{% endexercise %}