Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function extract(array) {
- let max = Number.MIN_SAFE_INTEGER;
- let newArray = array.filter(number => {
- if (number > max) {
- max = number;
- return true;
- } else {
- return false;
- }
- });
- console.log(newArray);
- }
- extract([1,
- 3,
- 8,
- 4,
- 10,
- 12,
- 3,
- 2,
- 24]
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement