I could be wrong, but given the pattern of activity for this user, it looks like another Founders and Coders deal where they'll leave as soon as they've got one published.. author may not be coming back.

The reason is your code is mutating the input array, and because the control function uses it afterwards, it gets the wrong expected value.
@kamilalew get the expected value first or pass a copy to the user's function.

It seems random tests with negatives are incorrect.
We have:
Test for random array: [26,-9,-20,-7,26,-22,-21,-18,17,-10,23,18,-16,-8,13,-26,14,-13,-23]
Expected: 52, instead got: 423
Test for random array: [-12,-10,-20]
Expected: 10, instead got: 12
Test for random array: [-4,9,-9,1,-11,-3,11,5,-3,-3,1,-10,-4,1,10,10,-3,5,6,-12]
Expected: 23, instead got: 164
Test for random array: [19,17,9,-15,8,17,10,-17,-18,3,-16,0,-5,14,-7,10,-14,1,-19,16,12,9,-10]
Expected: 38, instead got: 339
Test for random array: [-26,22,7,-11,20]
Expected: 48, instead got: 112
Test for random array: [13,18,3,21,21,18,-19,10,2,-20,-4,-22,17,-11,-22,14,1,-1,-22,4,-22,15,1,-17,5]
Expected: 43, instead got: 464
Test for random array: [-1,9,-10,12,-4,8,-1,11,-6,14,-5,-1]
Expected: 24, instead got: 160
Test for random array: [7,6,6,-6,-5,3,-7,1,-8,-5,-1,3]
Expected: 15, instead got: 60
Test for random array: [7,2,-1,0,2,-4,-11,1,-1,-7,1,2,-6,-6,-1,5,-1,6,-5,10,-11,7,4]
Expected: 21, instead got: 153
Test for random array: [-6,-9,6,-16,-5,-7,15,-27,9,23,18,23,-23]
Expected: 50, instead got: 223
Test for random array: [-7,14,-1,15,6,2,24,-12,26,22,8,-3,-12,20,-4,9]
Expected: 38, instead got: 268
Test for random array: [27,-1,11,11,-19,20,4]
Expected: 46, instead got: 125
Test for random array: [-15,7,7,-13,7,6,-7,-11,9,0,-10,-10,-4,5]
Expected: 24, instead got: 134
Test for random array: [-16,-27,-20,19,-25,21,21,20,-1,18,-11,-10,-1,11]
Expected: 48, instead got: 239

Haskell : https://www.codewars.com/kumite/5bae46ea7631f074d00003ed?sel=5bae46ea7631f074d00003ed

Fixed.

You're not doing anything about the descending order.

This comment is hidden because it contains spoiler information about the solution

Because the array is not sorted in increasing order.

could use a couple more test cases:

`console.log(sumOfDifferences([1]), 0)`

`console.log(sumOfDifferences([]), 0)`

Maybe, but if that is the case, we should leave the issue open until it can be fixed if not by the author, by a power-user.

I could be wrong, but given the pattern of activity for this user, it looks like another Founders and Coders deal where they'll leave as soon as they've got one published.. author may not be coming back.

See the post below, fix it doing what I suggested there.

.

That would make sense. The only issue is that I still have some tests passing with more than one number input arrays.

Edit: Ignore this, I copied the array and it works fine.

The reason is your code is mutating the input array, and because the control function uses it afterwards, it gets the wrong expected value.

@kamilalew get the expected value first or pass a copy to the user's function.

No.

But I missread about only descending diffs.

Sorry.

Erm, these look totally fine to me. What do you think is wrong with them?

It seems random tests with negatives are incorrect.

We have:

Test for random array: [26,-9,-20,-7,26,-22,-21,-18,17,-10,23,18,-16,-8,13,-26,14,-13,-23]

Expected: 52, instead got: 423

Test for random array: [-12,-10,-20]

Expected: 10, instead got: 12

Test for random array: [-4,9,-9,1,-11,-3,11,5,-3,-3,1,-10,-4,1,10,10,-3,5,6,-12]

Expected: 23, instead got: 164

Test for random array: [19,17,9,-15,8,17,10,-17,-18,3,-16,0,-5,14,-7,10,-14,1,-19,16,12,9,-10]

Expected: 38, instead got: 339

Test for random array: [-26,22,7,-11,20]

Expected: 48, instead got: 112

Test for random array: [13,18,3,21,21,18,-19,10,2,-20,-4,-22,17,-11,-22,14,1,-1,-22,4,-22,15,1,-17,5]

Expected: 43, instead got: 464

Test for random array: [-1,9,-10,12,-4,8,-1,11,-6,14,-5,-1]

Expected: 24, instead got: 160

Test for random array: [7,6,6,-6,-5,3,-7,1,-8,-5,-1,3]

Expected: 15, instead got: 60

Test for random array: [7,2,-1,0,2,-4,-11,1,-1,-7,1,2,-6,-6,-1,5,-1,6,-5,10,-11,7,4]

Expected: 21, instead got: 153

Test for random array: [-6,-9,6,-16,-5,-7,15,-27,9,23,18,23,-23]

Expected: 50, instead got: 223

Test for random array: [-7,14,-1,15,6,2,24,-12,26,22,8,-3,-12,20,-4,9]

Expected: 38, instead got: 268

Test for random array: [27,-1,11,11,-19,20,4]

Expected: 46, instead got: 125

Test for random array: [-15,7,7,-13,7,6,-7,-11,9,0,-10,-10,-4,5]

Expected: 24, instead got: 134

Test for random array: [-16,-27,-20,19,-25,21,21,20,-1,18,-11,-10,-1,11]

Expected: 48, instead got: 239

## Loading more items...