const scrambleWord = (word) => { if (word.length <= 3) { return word; } const random = create(word.toLowerCase()); const newWord = word.split(''); const firstLetter = newWord.shift(); const lastLetter = newWord.pop(); for (let i = 0; i < word.length; i += 1) { const from = random(word.length); const to = random(word.length); newWord.splice(to, 0, newWord.splice(from, 1)[0]); } newWord.unshift(firstLetter); newWord.push(lastLetter); return newWord.join(''); }