Monotonic Coding Problem




function isMonotonic(array) {
// Write your code here.
let increasing = true
let decreasing = true
if(array.length === 0 || array.length === 1) {
return true
for(let i = 0; i < array.length; i++) {
if(array[i] > array[i + 1]) {
increasing = false
if (array[i + 1] > array[i]) {
decreasing = false
return increasing || decreasing




Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

A Simple HTTP/HTTPS Proxy in Node Js

Scalable Redux architecture for React Projects with Redux-Saga and Typescript

Handling API in React Native


Here’s how the world’s most innovative companies use React Native (+5 great examples)

Shallow Copying vs Deep Copying

Custom Error Message Using Joi

Async await || Love your JS code

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Nerly Ton

Nerly Ton

More from Medium

Daily Post #404 Handling errors

Why outsourcing works, and what we should learn from it.

What tasks does DevOps solve?

Understanding the Fusion Reaction through Magnets