#896. Monotonic Array
An array is monotonic if it is either monotone increasing or monotone decreasing.
An array A is monotone increasing if for all i <= j, A[i] <= A[j]. An array A is monotone decreasing if for all i <= j, A[i] >= A[j].
Return true if and only if the given array A is monotonic.
/**
* @param {number[]} A
* @return {boolean}
*/
var isMonotonic = function(A) {
const originStr = A.join('');
var insort = A.sort((a,b) => a-b);
let flag=1;
let inStr = insort.join("");
let deStr = insort.reverse().join("");
if(originStr !== inStr && originStr != deStr) {
return false;
}
else {
return true;
}
};