About this challenge
Type Coercion: Sum as Number is a easy javascript quirks coding challenge. It explores a surprising corner of JavaScript's behavior — the kind of gotcha that causes real bugs. Write your solution in the editor above, run it against the test cases, and get instant feedback — free, in your browser, no sign-up.
Show a hint & approach (spoiler)
Hint: Coerce both inputs to Number() before adding.
Approach: The unary + or Number() forces numeric conversion. Without it, string + number returns a string due to JS overloading + for concatenation.
Keep practicing
Browse all coding challenges, or build intuition for the underlying concepts with the algorithm visualizers and the developer cheatsheets.