← Back to challenges

Fix the Broken Code

JavaScriptHardbugslanguage_fundamentalssorting

Instructions

A student learning JavaScript was trying to make a function that sorts all the letters of a word, but their code is broken, and they can't figure out why.

Spot and fix the error(s) in the code to make the function work.

Examples

sortWord("dcba") ➞ "abcd"

sortWord("Unpredictable") ➞ "Uabcdeeilnprt"

sortWord("pneumonoultramicroscopicsilicovolcanoconiosis") ➞ "aacccccceiiiiiilllmmnnnnooooooooopprrsssstuuv"

Notes

Input is a word.

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Default Mood