The program has to put all the letters together but it is not working. I've tried with the debugger but does not show any errors. The code:
var phrase = [ 'h', 'e', 'l', 'l', 'o',' ', 'w', 'o', 'r', 'l', 'd' ];
let sentence: string[] = createSentence(phrase);
sentence.forEach(letter => {
console.log(letter);
});
function createSentence(letters: string[]): string[]
{
var add = "";
var result: string[] = [];
phrase.forEach(unionL => {
if (unionL != ' ') {
add += unionL;
} else {
result.push(add);
add = "";
}
});
return result;
}