JSFiddle - React, Tailwind, and code Playground
JavaScript
const arr = [
"media-center",
"events",
"current-events",
];
const arr2 = [];
arr.forEach((value, index) => {
if (index === 0) {
arr2.push(value);
} else {
arr2.push(arr2[index - 1] + '-' + value);
}
});
console.log(arr2);