Domanda di colloquio di Forio

I was expecting some JavaScript questions related to DOM manipulation, instead It was a pure algorithm and data structure question: Revert words in a sentence. For example given "hello world", you need to return "world hello". I was so nervous that at I first I reverted the entire sentence character by character. I was able to correct it in the end but obviously he wasn't very satisfied as it eventually took me a long time to solve this problem.