DOM Manipulation

Read Then Write

Read Then Write

DOM updates often depend on what the page already says. In that case, read the current text first, convert it to the type your calculation needs, then write the new display text.

The common mistake is changing a separate number variable while the visible DOM count stays stale.

Your task: Read the current cart count from the page, add one item, then update both the count and the summary so they show the new total.

Free with a JS Exercises account

Sign in to start coding, run your solution, and keep your progress saved for later. No payment needed.

By continuing, you agree to our Terms and Privacy Policy. We'll send occasional product updates and news. You can unsubscribe anytime.

Read Then Write

DOM updates often depend on what the page already says. In that case, read the current text first, convert it to the type your calculation needs, then write the new display text.

The common mistake is changing a separate number variable while the visible DOM count stays stale.

Your task: Read the current cart count from the page, add one item, then update both the count and the summary so they show the new total.

Free with a JS Exercises account

Sign in to start coding, run your solution, and keep your progress saved for later. No payment needed.

By continuing, you agree to our Terms and Privacy Policy. We'll send occasional product updates and news. You can unsubscribe anytime.

Console

Run code to see output.