JS exercise from The Good Parts