code assignment main.js with corrections