Skip to content

Instantly share code, notes, and snippets.

@SavvasStephanides
Last active February 20, 2024 11:39
Show Gist options
  • Save SavvasStephanides/bdb3e0eec6062f17676e46cf2bfc4551 to your computer and use it in GitHub Desktop.
Save SavvasStephanides/bdb3e0eec6062f17676e46cf2bfc4551 to your computer and use it in GitHub Desktop.
// This is your original array:
const animals = ['panda', 'turtle', 'giraffe'];
function convertToBaby(animalsArray){
// Start with an empty array. You will populate these in your loop:
const babyAnimals = [];
// Since it specifically asks for a loop:
for(var i = 0 ; i < animals.length ; i++){
// push() basically adds something at the end of an array:
babyAnimals.push(`baby ${animalsArray[i]`)
}
return babyAnimals
}
convertToBaby(animals);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment