I have a situation where I'm trying to join the array of strings only if it has a value. I did using let variable, but I wonder can I do this using map. I'm very mindful on the position, so I used in this way.
const [hours, minutes, seconds] =["", "10", ""]
let time = "";
if (hours) {
time += `${hours}h `;
}
if (minutes) {
time += `${minutes}m `;
}
if (seconds) {
time += `${seconds}s`;
}
console.log(time)
Will I be able to do this using map, filter and join?