updated script.js

Added variables and anonymous function to the script