javascript solution for 9