Manipulating js objects solution