Having a hard time understanding for loops in arrays. Trying to create a Thank You card creator and these are the steps I'm trying to follow:
- Create a new, empty array to hold the messages
- Iterate through the input array and inside the loop build out the 'thank you' message for each name using string interpolation, then add that message to the new array you created
- After the loop finishes and all of the messages have been added to the new array, return the new array.
const names = []
function writeCards(names, event) {
for (let i = 0; i < names.length; i++) {
console.log(`Thank you, ${names[i]} for the wonderful ${event} gift!`);
return names;
}
Not sure if I'm on the right track. Thanks for your help!
well the i had this issue
i had an empty array outside a loop and wanted to update it inside a loop
and finally return an array with alot of indexes
this is my first answer here