+ 1
Why I get an error here?
Check my code. https://code.sololearn.com/W6iZXn9ras44/?ref=app
2 Answers
+ 3
The problem is in the loop, when you reach array.length you want to compare the element y+1 which is array.length => it's obviously out of array bonds. You can see the correct upper limit in the loop. Don't forget the index of last element of array is array.length - 1.
https://code.sololearn.com/W3Clv7InM0f7/?ref=app
+ 1
array is not defined i guessđ