How would I loop through an array in Javascript, add a word, and then return an array (without using map)?
var convertToBaby = (array) => {
for (var i =0; i < array.length; i++) {
console.log('baby '+ array[i]);
}
};
const animals = ['panda', 'turtle', 'giraffe', 'hippo', 'sloth', 'human'];
convertToBaby(animals);
/*Returns
baby panda
baby turtle
baby giraffe
baby hippo
baby sloth
baby human */
// Should return ['baby panda', 'baby turtle', 'baby giraffe', 'baby hippo', 'baby sloth', 'baby human'];
const babies = [];then push() to it instead of logging.map?.push()is allowed, I assume, given that it's still a method?