Update script.js

Added comments for better understanding.