solution to an assessment of javascript