Solutions to Coderbyte in Javascript