Logical Coding Questions In Javascript