Practice
JavaScriptData StructuresReactConcepts
Sign in
← Back to problems

BigInt Sum

Numbers, Dates & Timersmedium

Course · Section 12: Numbers, Dates, Intl and Timers · Lecture 185: Working with BigInt

Implement `bigSum(a, b)` where `a` and `b` are numeric strings, returning their sum as a string using BigInt (to avoid precision loss on huge numbers).

Sample tests

Input: bigSum("10", "20")
Output: "30"
Input: bigSum("999999999999999999", "1")
Output: "1000000000000000000"

+ 1 hidden test run on Submit.

Hints

Common pitfalls
  • Regular numbers lose precision past 2^53; BigInt does not.
  • BigInt values cannot be mixed with regular numbers.
Approach & explanation (try first)

BigInt arithmetic stays exact for very large integers; converting to a string returns a comparable value.

Loading...
⌘/Ctrl + Enter

Run your code to see results.