ruby week 1 in javascript