How can I achieve the desired output for this input parameter?
displayText("you and me");
expected output:
["you and me", "you and", "and me", "you", "and", "me"]
I have attempted to solve it using the following code, but the results are incorrect. Here is my current code:
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
}