2018-10-12 15:37:13 -04:00
---
title: Add Items to an Array with push() and unshift()
---
2019-07-24 00:59:27 -07:00
# Add Items to an Array with push() and unshift()
2018-10-12 15:37:13 -04:00
2019-07-24 00:59:27 -07:00
---
## Hints
### Hint 1
2018-10-12 15:37:13 -04:00
- Just like the example given, use the `.unshift()` method on the array to add elements to the start of the array and use the `.push()` method to add elements to the end of the array.
2019-07-24 00:59:27 -07:00
---
## Solutions
< details > < summary > Solution 1 (Click to Show/Hide)< / summary >
2018-10-12 15:37:13 -04:00
```javascript
function mixedNumbers(arr) {
// change code below this line
2019-07-24 00:59:27 -07:00
arr.unshift("I", 2, "three");
arr.push(7, "VIII", 9);
2018-10-12 15:37:13 -04:00
// change code above this line
return arr;
}
// do not change code below this line
2019-07-24 00:59:27 -07:00
console.log(mixedNumbers(["IV", 5, "six"]));
2018-10-12 15:37:13 -04:00
```
2019-07-24 00:59:27 -07:00
< / details >