Added explicit onOffer and onError functions to improve readability in hello-world

Change-Id: Id3ef5de40583b47a588967cd0f9c246cbe545ed2
Unified JavaScript logic in tutorials

Change-Id: I59761f4dc0ffbd1e0b05c01b37df4ba67034eff0