I was trying to add a individual digits of an BigInt number to an array. When I did that I encountered the above error.
Below is the code Snippet:
var plusOne = function(digits) {
const outputValue = BigInt(digits.join("")) + 1n;
let arr = [];
while(outputValue > 0)
{
arr.push(BigInt(outputValue%10));
outputValue = BigInt(Math.floor(outputValue/10));
}
return arr;
};
console.log(plusOne([6,1,4,5,3,9,0,1,9,5,1,8,6,7,0,5,5,4,3]));
Can you please tell me what am I doing wrong?
I tried making the push into the array as a BigInt but it never worked. I want to add the individual digits to the array from the BigInt Number.