Completed isMonotone function. Codewars 7 kyu challenge.