Need to work with a really big number in JavaScript? Larger than a normal int? BigInt is your answer!
Say, for example, you were trying to solve the “A Very Big Sum” problem on HackerRank. The code is simple with BigInt():
function aVeryBigSum(ar) {
// Write your code here
let sum = 0n;
for (let i = 0; i < ar.length; i++) {
sum = sum + BigInt(ar[i]);
}
return sum;
}