Javascript basic programming rules with no Jquery