Strictly Increasing or Decreasing

THE CHALLENGE

Create a function that takes an array and determines whether it's strictly increasing, strictly decreasing, or neither.

Please notice that I use print in the code instead of console.log to show the result in my built-in console below. However, you should use console.log to show the result in your normal console

THE CODE

        
          // WEEK 5 → DAY 2 dont publish nadeem
          // Strictly Increasing or Decreasing
          
          function check(arr) {
            if (new Set(arr).size !== arr.length) {
              return 'neither';
            } else if (arr[1] > arr[0]) {
              return 'increasing';
            } else {
              return 'decreasing';
            }
          };
          
          print(check([1, 2, 3, 4, 5]));
          print(check([5, 4, 3, 2, 1]));
          print(check([1, 2, 2, 4, 5]));
        
      

THE EXECUTION RESULT

        
      

the built-in console was provided by my amazing trainer Sorin. PrismJS plug-in is used to show the code