logo CodeStepByStep logo

sorted

Language/Type: JavaScript arrays traversals

Write a function named sorted that accepts an array of numbers as a parameter and returns true if the array is in sorted order and false if not.

For example, if an array named arr stores [1.5, 4.3, 7, 19.5, 25.1, 46.2] respectively, the call of sorted(arr) should return true. You may assume the array has at least one element and contains only numbers. A one-element array is considered to be sorted. Do not modify the array passed in.

Function: Write a JavaScript function as described, not a complete program.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.