Created
April 26, 2020 02:37
-
-
Save or9/53caad3157123f70e75517871e0463ad to your computer and use it in GitHub Desktop.
Check if an array of numbers is ascending.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isAsc (list = []) { | |
return list.reduce((curr, acc, index, arr) => { | |
if (curr === false) return false; | |
if (acc > curr) { | |
if (index === arr.length - 1) { | |
return true; | |
} else { | |
return acc; | |
} | |
} else { | |
return false; | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment