Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript

Rashad Nelson
Rashad Nelson
5,653 Points

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
217,519 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
217,519 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.

Rashad Nelson
Rashad Nelson
5,653 Points

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