Is there an alternative way to iterate through an array in Javascript, append a word, and then produce a new array (without utilizing map)?
var addBabyPrefix = (array) => {
for (var i =0; i < array.length; i++) {
console.log('baby '+ array[i]);
}
};
const animals = ['panda', 'turtle', 'giraffe', 'hippo', 'sloth', 'human'];
addBabyPrefix(animals);
/*Returns
baby panda
baby turtle
baby giraffe
baby hippo
baby sloth
baby human */
// Expected output: ['baby panda', 'baby turtle', 'baby giraffe', 'baby hippo', 'baby sloth', 'baby human'];