Problem 36 JS solution