Skip to content

Instantly share code, notes, and snippets.

@or9
Created April 26, 2020 02:37
Show Gist options
  • Save or9/53caad3157123f70e75517871e0463ad to your computer and use it in GitHub Desktop.
Save or9/53caad3157123f70e75517871e0463ad to your computer and use it in GitHub Desktop.
Check if an array of numbers is ascending.
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