Untitled
unknown
javascript
3 years ago
418 B
8
Indexable
export function order(words: string): string { const splittedPhrases = words.split(' '); const orderred = splittedPhrases.reduce((accumulator, phrase) => { const copyPhrase = phrase.repeat(1); const currentPosition = copyPhrase.replace( /^\D+/g, '')[0]; return { [currentPosition] : phrase, ...accumulator }; }, {}); return Object.values(orderred).join(' '); }
Editor is loading...