Problem 1 in js and rb