curriculum/challenges/english/blocks/daily-coding-challenges-javascript/681cb1afdab50c87ddb2e516.md
Given a string, return a jumbled version of that string where each word is transformed using the following constraints:
jbelmu("hello world") should return "hello wlord".
assert.equal(jbelmu("hello world"), "hello wlord");
jbelmu("i love jumbled text") should return "i love jbelmud text".
assert.equal(jbelmu("i love jumbled text"), "i love jbelmud text");
jbelmu("freecodecamp is my favorite place to learn to code") should return "faccdeeemorp is my faiortve pacle to laern to cdoe".
assert.equal(jbelmu("freecodecamp is my favorite place to learn to code"), "faccdeeemorp is my faiortve pacle to laern to cdoe");
jbelmu("the quick brown fox jumps over the lazy dog") should return "the qciuk borwn fox jmpus oevr the lazy dog".
assert.equal(jbelmu("the quick brown fox jumps over the lazy dog"), "the qciuk borwn fox jmpus oevr the lazy dog");
function jbelmu(text) {
return text;
}
function jbelmu(text) {
return text
.split(' ')
.map((word) => {
if (word.length <= 3) return word;
const first = word[0];
const last = word[word.length - 1];
const middle = word
.slice(1, -1)
.split('')
.sort()
.join('');
return first + middle + last;
})
.join(' ');
}