How do I display the input parameter like this:
displayText("you and me");
expected output:
["you and me", "you and", "and me", "you", "and", "me"]
I have tried like the following code, but the results are still wrong. My code is like this now.
let displayText = (txt) => {
let output= []
for(let i = 0; i < txt.length; i++) {
for(j = i + 1; j < txt.length + 1; j++) {
output.push(txt.slice(i, j))
}
}
return output
}