js exercise using math functions