R
Reactiflux

Script – 00-49 Jan 31

Script – 00-49 Jan 31

SScript1/31/2022
I'm very confused at this occurrence derp How is
if (grid[0].sort()) {
console.log(true)
}
if (grid[0].sort()) {
console.log(true)
}
actually sorting grid[0]? is that a normal thing? I do not understand whats going on
UUUnknown User1/31/2022
Message Not Public
Sign In & Join Server To View
SScript1/31/2022
the if statement is actually sorting grid whereas I'm just trying to check if grid is sorted
Aacemarke1/31/2022
yes, because you're calling .sort(), and the if statement is comparing what that returns .sort() does not do any kind of a "is this sorted?" check
UUUnknown User1/31/2022
Message Not Public
Sign In & Join Server To View
Aacemarke1/31/2022
and there really isn't an easy way to check if an array is sorted at least not any kind of built-in API
UUUnknown User1/31/2022
Message Not Public
Sign In & Join Server To View
SScript1/31/2022
and this exercise says to do so
SScript1/31/2022
taking a look at this.
Aacemarke1/31/2022
yeah, so at that point you have to do something like what iggy showed the point is that there is no generic "is this sorted" function the answer to "is this sorted" entirely depends on what is inside the array, and that's specific to your app so yeah, you most likely would need to do some kind of pairwise comparisons all the way down the array
UUUnknown User1/31/2022
3 Messages Not Public
Sign In & Join Server To View

Looking for more? Join the community!

R
Reactiflux

Script – 00-49 Jan 31

Join Server