Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(arr){
- const newArr = []
- let prevNum = arr[0]
- newArr.push(prevNum)
- for(let i = 1; i < arr.length; i++){
- currentNum = arr[i]
- if(currentNum >= prevNum){
- newArr.push(currentNum)
- prevNum = currentNum
- }
- }
- console.log(newArr.join(` `));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement