Skip to content

Commit

Permalink
Homeworks-2: task 1 has been completed
Browse files Browse the repository at this point in the history
  • Loading branch information
dtr200 committed Jun 15, 2021
1 parent dbba16c commit dd98a25
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions homework-lecture-2/growing-list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
function isGrows(list){
list = list.split(' ')
.map(num => Number(num));

if(!list.length || list.length === 1)
return 'NO';

let prev = list[0];

for(let i = 1; i < list.length; i++){
if(list[i] <= prev)
return 'NO';
prev = list[i];
}

return 'YES';
}

isGrows('1 7 9');
isGrows('1 9 7');
isGrows('2 2 2');

0 comments on commit dd98a25

Please sign in to comment.