Hello Govarthini Rajan,
Have you added the script file into your project directory inside theme and added a script call inside index.html, Because it seems the method not defined. You can add the method in two ways,
You can add the version based on your feasibility, I gave the sample for version 5
Hope this helps, Thanks!
Are you able to see more detailed information in the Java Script Console of your browser?