12 lines
322 B
TypeScript
12 lines
322 B
TypeScript
|
export function wordFactorial(words: string[]): string[] {
|
||
|
const combinations: string[] = [];
|
||
|
for (let i = 0; i < words.length; i++) {
|
||
|
let inner = '';
|
||
|
for (let ii = i; ii < words.length; ii++) {
|
||
|
inner += (ii > i ? ' ' : '') + words[ii];
|
||
|
combinations.push(inner);
|
||
|
}
|
||
|
}
|
||
|
return combinations;
|
||
|
}
|