Update client.js

added a lot of comments for code explanations