I'm tying to display the first letter of every array element only once along with the main element title. I have listed the example below where you can see the list along with it's respected first letter. I want the list to appear as it is, but don't want to get their first letter repeated. https://jsfiddle.net/z42u1d9o/
My code:
var cars = ["Brown", "Blue", "Bingo", "Vietnam", "America", "India", "Volvo", "Saab", "Ford", "Fiat", "Audi"];
var text = "";
cars = cars.sort();
return cars.map(item => {
var firstLetter = item.split('')[0];
text += item + '-' +firstLetter + "<br>";
document.getElementById("demo").innerHTML = text;
})