Assesment wanted for: Test your skills: Arrays 3

Hi, I just finished this now and it seems to be working.
However when i use the split to bring it back to an array it looks like there is another item with no value added.
the reason why i use pop() before using join() to make the array back to a string.
Here’s my link - https://codepen.io/BobOy/pen/WNQYQVO

link to the activity

Thanks

Hi there @Bob_Oy, and welcome to the community!

You’ve done really well here — this was quite a tough assignment. Your code works great, and you have used forEach() rather nicely.

In terms of the problem that caused you to use pop(). Your use of forEach is correct, but inside it you are building a new string that you then split. When you’ve built the string, you end up with a comma on the end of it. This is ecause for each item in the array, you are running this:

txt = txt + value + ' ('+ index +'),';

and you are not removing the comma at the end of it before you then split it.

In our version — https://github.com/mdn/learning-area/blob/master/javascript/introduction-to-js-1/tasks/arrays/marking.md#task-3 — for each item in the array we build a new array item, then copy it back to the array to replace the original array item.

thanks for the feedback Chris, now i know how to do it the right way :slight_smile: