I want to join the elements of an array separated by commas and the first letter of each element to be capital, this should not affect the object values itself.
For example:
obj= ["apple","orange","lemon"]
Output should be:
Apple, Orange, Lemon.
Here is what I have tried and failed with:
obj.charAt(0).toUpperCase().join(', ')
>Solution :
Here is the code:
let a = ['apple', 'orange', 'lemon'];
let res = a.map(fruit => fruit.charAt(0).toUpperCase() + fruit.slice(1));
console.log(res); // [ "Apple", "Orange", "Lemon" ]