Update script.js

had if(undefined) bug