Foundations

Fix Plus Behavior

Fix Plus Behavior

The + operator adds numbers, but it joins text when either side is a string. Numeric-looking text still behaves like text until you convert it.

Your task: This code should store the numeric total of the cart count and the bonus count. Fix the calculation so totalItems is the number 8, then log it.

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.

Fix Plus Behavior

The + operator adds numbers, but it joins text when either side is a string. Numeric-looking text still behaves like text until you convert it.

Your task: This code should store the numeric total of the cart count and the bonus count. Fix the calculation so totalItems is the number 8, then log it.

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.