Hi, I am having a little bit of challenge with this particular exercise, I am a little bit confused. I have given my best but seems something wasn’t clicking. Though here is my solution, Array 3 Solution Codepen
Regarding the loop:
Your first step to create the new element inside the loop is correct. The line // Don't edit the code below here! does also mean we are not allowed to copy this code into our own code. These “untouchable” lines of code tell us the exercise expects a single string of all the data from the array inside the variable myString.
I took the correct parts of your loop and added some pseudo code to help you understand the steps:
for(let i = 0; i < myArray.length; i++) {
const value = `${myArray[i]} ${i}`
/* Set the current array element to the new value */
}
/* Use the join() method of the array to create the myString variable */
Try to replace each of my comment lines with a single assignment. The resulting code is simpler than you may think. So don’t think to far. I hope that gives you enough support to solve the tasks. If not, just ask.
Congratulations on the improvement! Now the code works as expected
I have just one comment on how you named your variable. It’s a bit confusion that myString is first an array and then gets converted to a string. I think it would be easier to understand if you would use a variable newArray which gets the new elements and then use const myString = newArray.join(' - ').
Of course this isn’t really a problem in this short little exercise, but it’s a important thing to keep in mind when working on bigger projects where you come back after some months and are scratching your head. Your future self will thank you for good variable names in your code.
Happy coding,
Michael
PS: Your email address is visible in your post. I think it somehow ended up in the optional “name” field of your profile. I recommend removing it.