Tell us what’s happening:
Describe your issue in detail here.
Most of the points are correct, but I can’t figure out where I am going wrong.
Need help!
Not sure if this will solve your problem, but one error I see is:
for(let i=0; i<arr.length; i++)
should be:
for(let i=0; i<arr.length -1; i++)
Remember, the array index starts at zero, so if your array has a length 5, the indexes are 0 to 4 (hence the need to subtract 1 in the stop condition).