add comments to javascript to clarify what the code is doing