Hey,@chrisdavidmills
Need assessment on the below tasks. and I am stuck at the last one. Please Guide me on the same.
Good Day…!!
Hey,@chrisdavidmills
Need assessment on the below tasks. and I am stuck at the last one. Please Guide me on the same.
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 . 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 doesn’t
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, good job!
Thanks for doing the review, @louisono!
And well done on some nice work, @Coder_In_Progress
@chrisdavidmills Thank you…!!
@louisono,Thank you much for the explanation, that helped me a lot.
Good Day…!!