I'm learning JavaScript, and practicing I came across this exercise which I don't know how to solve, thanks in advance to whoever can explain how and why.
Assignment of the exercise:Given these three arrays:
carnivores = ['lion', 'shark', 'wolve', 'puma', 'snake'];
herbivores = ['elephant', 'giraffe', 'gacelle', 'hippo', 'koala'];
omnivores = ['human', 'monkey', 'dog', 'bear', 'pig'];
Define a variable called animals that references the previous arrays: [carnivores, herbivores, omnivores].
Create a FOR loop that changes each string in the array for each diet to be plural. For example: ['lion',...] -> ['lions',...]
Where I have problems to solve is in point 2, I leave you my code:
var carnivores = ['lion', 'shark', 'wolve', 'puma', 'snake'];
var herbivores = ['elephant', 'giraffe', 'gacelle', 'hippo', 'koala'];
var omnivores = ['human', 'monkey', 'dog', 'bear', 'pig'];
var animals = [].concat(carnivores, herbivores, omnivores);