finished problem #10 on JavaScript