Dubstep

Kata 8

by trentHarlem

JavaScript

/* const songDecoder = (song) => {
return song
.split('WUB')
.filter(i => (i !=='')?true:false)
.join(' ')
} */

const songDecoder = (song) => {
return song
.split('WUB')
.filter(Boolean)
.join(' ')
}

function fart(gas) {
return 'pfft'
}


console.log(songDecoder("AWUBBWUBC"), "A B C","WUB should be replaced by 1 space");
console.log(songDecoder("AWUBWUBWUBBWUBWUBWUBC"), "A B C","multiples WUB should be replaced by only 1 space");
console.log(songDecoder("WUBAWUBBWUBCWUB"), "A B C","heading or trailing spaces should be removed");