week 8 and 9, js, translate to js: solution