Solving problems using JavaScript