"Assessment Wanted for Arrays1"

Hey,@chrisdavidmills
Need assessment on the below tasks. and I am stuck at the last one. Please Guide me on the same.

Arrays1
Arrays2
Arrays3

Good Day…!!

hello @Coder_In_Progress, there is a method for arrays called map, that allows you to apply a function to every element of an array. I encourage you to read the documentation and find your own solution. If you’re still stuck after that, this is the solution I came up with:
Insert this line before let myString = myArray.join(' - ');

myArray = myArray.map((el, index) => el + ` ${index}`);

I just had a look at your solution for the first test and it looks a little odd to me :thinking:. You’re using shift and unshift to change the first value which is a little more complicated than using the bracket notation:

myArray[0] = 'Barfi';

This would have the same effect and you could as easily change the second item of the Array by writing (for instance):

myArray[1] = 'Ginseng';

Also, in the end you write:

myArray = `Chai,${myArray}`;

And this :stop_sign: doesn’t :stop_sign: add an item to the beginning of your Array (although it may look like it does), it actually turns the variable myArray into a string which is 'Chai, followed by the content of myArray, this is generally called string interpolation. The use of unshift here is more appropriate.

And finally, your solution for the second problem is perfect, :ok_hand: good job!

Thanks for doing the review, @louisono!

And well done on some nice work, @Coder_In_Progress

1 Like

@chrisdavidmills Thank you…!!

@louisono,Thank you much for the explanation, that helped me a lot.

Good Day…!!