Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Can i get clarification on a concept i am trying

I tried a random project and i understand a lot of it- i want to use a join to the Array is written out regular and not list. I am not sure how to use the join. It works but iterates all items and list each item over and over. My thoughts- I make the array and after i once created then add properties. I also tried making a let var = array name then try to add properties to let var. how do you add Xs properties to array. convertToBaby = (arr) => { const babyArr = []; for (i = 0; i < arr.length; i++) { // let babeName = one attempt babyArr.push(baby ${arr[i]}); console.log(babyArr.join(', ')); // babeName.join(', ') one attempt

} return babyArr; };

thank you

Steven Parker
Steven Parker
231,248 Points

When posting code, use Markdown formatting to preserve the code's appearance and retain special symbols. An even better way to share code and make your issue easy to replicate is to make a snapshot of your workspace and post the link to it here.

1 Answer

Steven Parker
Steven Parker
231,248 Points

Without the formatting it's a bit hard to tell the code from the comments, but this function does appear to create a new array and add elements to it one at a time by copying from another array.

The reason it keeps repeating the list items is that the log line is inside the loop where the items are being added. Just move that line so it happens after the loop finishes if you want to see the entire array just one time.

Thanks for always reviewing and giving feedback on my code. Really appreciate it.