did problems 1-3 in javascript