JavaScript problems for homework