the last three digits are 543 but when convert it to string and into an integer to add plus 1 the last three digits are 000 instead of 544
var plusOne = function(digits) {
const convert = digits.join().split(',');
const convert2 = convert.join('');
const convert3 = parseInt(convert2);
console.log(convert2)
console.log(convert3 +1)
return Array.from(convert3.toString()).map(Number);
};
console.log(plusOne([6,1,4,5,3,9,0,1,9,5,1,8,6,7,0,5,5,4,3]));
const convert = digits.join().split(',');
const convert2 = convert.join('');
const convert3 = parseInt(convert2) +1;
return Array.from(convert3.toString()).map(Number);
ILM
May 24, 2024, 8:59am
3
You can’t use normal numbers here, as it’s above the highest safe integer, it’s above the precision
I’m confused now can you dumb it down for me
For the Number datatype in Javascript, integers can only be represented without loss of precision in the range -253 + 1 to 253 - 1. Which is about 9x1015 . Your number is a digit or two too large for JavaScript to handle as a Number.
system
Closed
November 23, 2024, 10:56am
6
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.