Solución
solution.tsTypeScript
function uniqueWords(text: string): string[] {
if(text === "") return [];
let words = text.split(' ');
let wordCount:Record<string, number> = {};
for(let i = 0; i < words.length; i++) {
!wordCount[words[i].toLowerCase()]? wordCount[words[i].toLowerCase()] = 1 : wordCount[words[i].toLowerCase()] += 1;
}
const uniqueWords:string[] = []
for(const [key,value] of Object.entries(wordCount)) {
if(value === 1){
uniqueWords.push(key)
}
}
return uniqueWords;
}
// Do not modify: needed to evaluate the result.
export { uniqueWords };0respuestas