js loops and control using for ... in  loop