Jessica's JavaScriptmas Challenge

18. Array Previous Less


From your initial array of integers, create a new array of integers.

Each integer, i, in your array will be compared with the integers that come before it. The last number (from the left) that is smaller than integer i will take integer i's position in a new array. If there are no smaller integers to the left of integer i, -1 will take its place in the new array.

Example: The array [3, 5, 2, 4, 5] will return [-1, 3, -1, 2, 4].


Click for further explanation on example


Array of Integers: []



*Note: Numbers with decimal places will be rounded down





New Array: []