An elegant Javascript solution for the famous 'haha' problem