Adding updates to javascript function in Chapter 4 and improving assertion statements