var isMonotonic = function(nums) { let max = true let min = true if(nums[0] < nums[nums.length-1]) { for(let i =0; i <= nums.length-2; i++){ if(nums[i+1] < nums[i]) { max = false } } }else { for(let j =0; j <= nums.length-2; j++){ if(nums[j+1]>nums[j]) { min = false } } } return max && min }; console.log('这是',isMonotonic([1,3,2]))