L
L
lopyx2018-02-11 14:59:45
JavaScript
lopyx, 2018-02-11 14:59:45

How to put an array into another array without concatenating all elements?

var firstArray = ['cat', 'dog', 'elephant'];
var secondArray = ['blue', 'orange', 'grey'];
The end result should look like this:
var newArray = ['cat', 'dog', 'elephant', ['blue', 'orange', 'grey']];

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
WarriorKodeK, 2018-02-11
@lopyx

let newArray = [...firstArray, secondArray];

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question