First three problems in JS and Ruby