dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
1.4 KiB
1.4 KiB
id, title, challengeType, dashedName
| id | title | challengeType | dashedName |
|---|---|---|---|
| 68af0687ef34c76c28ffa54b | Challenge 32: Reverse Sentence | 28 | challenge-32 |
--description--
Given a string of words, return a new string with the words in reverse order. For example, the first word should be at the end of the returned string, and the last word should be at the beginning of the returned string.
- In the given string, words can be separated by one or more spaces.
- The returned string should only have one space between words.
--hints--
reverseSentence("world hello") should return "hello world".
assert.equal(reverseSentence("world hello"), "hello world");
reverseSentence("push commit git") should return "git commit push".
assert.equal(reverseSentence("push commit git"), "git commit push");
reverseSentence("npm install sudo") should return "sudo install npm".
assert.equal(reverseSentence("npm install apt sudo"), "sudo apt install npm");
reverseSentence("import default function export") should return "export function default import".
assert.equal(reverseSentence("import default function export"), "export function default import");
--seed--
--seed-contents--
function reverseSentence(sentence) {
return sentence;
}
--solutions--
function reverseSentence(sentence) {
return sentence.split(/\s+/).reverse().join(" ");
}