Got stuck on codewars js challenge

I got stuck in codewars challenge that is called +1 Array .
The challenge says:

I have 2 failed test cases which is big arrays and I tried too much to solve the problem.

Here is my code:

function upArray(arr) {
  // ...
  if (arr.length === 0) return null;
  for (let i = 0; i < arr.length; i++) {
    if (arr[i] > 9 || arr[i] < 0) return null;

  arr = arr.join("");
   let newArr;
  newArr = parseFloat(arr) + 1;
  newArr = newArr
    .map(function (i) {
      return parseFloat(i);
  return newArr;

The link to the challenge:

I will suspect that parseFloat is your problem here. The big arrays are intended to test precision, and your number failed the precision test.

Look at the last result:
[9, NaN, 2,2,3,3,7,2,0,3,6,8,5,4,7,7,6,NaN,NaN,3,6]

Bet you that when you converted that big number to a string, it gave you "9.223372036854776e+36".

The largest number that can be stored as a Number is 9007199254740991. (2^53 - 1)


(Notice how you lost 3 digits of precision in your answer, getting 000 at the end?)

You’re now in the world of BigInt. (Warning: Make sure your browser is compatible - no IE for you!)

Though I suspect the challenge is trying to make you manipulate the array, rather than doing number conversions? Just a thought.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.