Added beginning to javascript solution.