Practising Code Kata in Javascript