I was manipulating an array with a for loop. How can I do this with a forEach loop and a function? I tried this, but I'm getting an undefined in the output.
var pets = ['cat', 'dog', 'rat'];
pets = pets.forEach( function plural(value, index, array){
value = value + 's';
return value;
})
/*for ( i = 0; i < pets.length; i++) {
pets[i] = pets[i] + 's';
}
*/
console.log(pets);