First run at javascript solution