Hello everyone. I’m working on Arrays 3, and I’m stuck on the third exercise:
Go over each item in the array and add its index number after the name inside parentheses, for example
Ryu (0) . Note that we don’t teach how to do this in the Arrays article, so you’ll have to do some research.
My fiddle: https://jsfiddle.net/hassang97/2rt95efn/10/
(let me know if the link is broken).
My approach has been to loop over the array, and add the parenthesis besides each item in the array.
How can I find the index of each item in the array, and then loop over my array so as to add the index number besides each name.
Also, how can I put the index number for each item inside a parenthesis, and then add that to the Array.
I tried various things, including indexOf but that will only return the index of a specific item you are searching for, what if the array contains hundreds of items? I essentially want to find the final index, then starting at 0, loop over the array and add (i), incrementing by 1 each time until I reach the final item in the array.
Let me know if anything is unclear or if you have any questions! Thank you in advance.