added example code from head first java script