Enterprise Verified
2

JavaScript Type Coercion Output

intermediate • Output Predict
What is logged to the console by: `console.log("5" - 2 + "1")`?
console.log("5" - 2 + "1");
Helpful Hint:

The minus operator coerces string to number ("5" - 2 = 3), while the plus operator with a string concatenates (3 + "1" = "31").

Expected Solution:
31
Explanation: "5" - 2 evaluates to numeric 3. Then 3 + "1" performs string concatenation yielding "31".
Advertisement
Google AdSense Slot (LEADERBOARD)
Automated High-CTR Ad Rail • Set Publisher ID in config/adsense.php
Enterprise Operations Suite

Streamline Employee Payroll & Attendance Operations

Eliminate manual spreadsheet errors. Integrate automated attendance tracking, EPF/ESI statutory calculations, and custom GST invoices.

Copied!

AI Learning Assistant

Ready to explain & guide

Hello! I am your MBS Digital AI Tutor. Ask me to explain concepts, review code, or suggest debugging steps.

Quick Starters:
AI Tutor is thinking...