Skip to content

fix: remove embedded HTML script tags and fix global total bug in cart.js - #950

Open
saurabhhhcodes wants to merge 1 commit into
Anjaliavv51:mainfrom
saurabhhhcodes:fix/Retro-batch-5
Open

fix: remove embedded HTML script tags and fix global total bug in cart.js#950
saurabhhhcodes wants to merge 1 commit into
Anjaliavv51:mainfrom
saurabhhhcodes:fix/Retro-batch-5

Conversation

@saurabhhhcodes

Copy link
Copy Markdown

Bugs Fixed

1. Embedded <script> HTML tags in .js file

cart.js contained raw <script> and </script> HTML tags (lines 77-100) which are invalid JavaScript syntax. When the browser loads this file, it throws a SyntaxError at the <script> token, preventing all lazy-loading and image optimization code from running.

Fix: Removed the HTML <script>/</script> wrapper, leaving valid JavaScript code.

2. Global total variable accumulates across calculateBill() calls

The total variable was declared globally but never reset, causing the bill amount to grow on every call.

Fix: Made total a local variable inside calculateBill(). Updated the order button handler to read the current total from the DOM instead of relying on a stale global.

…lation bug in cart.js

- Remove embedded <script> HTML tags from .js file that caused syntax errors and prevented lazy-loading code from executing
- Fix global total variable that accumulated across multiple calculateBill() calls; now uses local variable and reads bill text for order validation

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job, @saurabhhhcodes! 🎉 Thank you for submitting your pull request. Your contribution is valuable and we appreciate your efforts to improve our project.We will promptly review your changes and offer feedback. Keep up the excellent work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant