creating exercism exercise in javascript