javascript apis ex1 and ex2