Exercise: record positions
Write a function function recordIndexes(nums) that returns an array of the indexes of all records of the array nums, in increasing order. A record is an element that is larger than every element before it; the first element is always a record.
recordIndexes([3, 1, 4, 1, 5])→[0, 2, 4]recordIndexes([5, 2, 5])→[0]recordIndexes([-5, -2, -9])→[0, 1]
Constraints: nums holds from 0 to 1000 integers, each from -1000000 to 1000000, and all of them may be negative; an element equal to the largest of the ones before it does not count as a record; for an empty array the result is an empty array.
The tests print the result through JSON.stringify: it turns an array into a string without spaces, for example [0, 2, 4] into [0,2,4].
Do not add extra imports unless the task says so explicitly.
Subscribe to take the course
The course is free. Sign in with Telegram and subscribe to the channel to open every lesson.