Question: Coding Practice Index of the first negative element of the array Write a function indexOfFirstNegative that takes array arr as argument and returns the index

 Coding Practice Index of the first negative element of the array

Coding Practice Index of the first negative element of the array Write a function indexOfFirstNegative that takes array arr as argument and returns the index of the first negative element of the array. If there are no negative elements or the array is empty, return the string 'no negative elements: Examples: The function indexOfFirstNegativec[0, 8, -6, 6, -91) should return 2 (since arr[2] = 0) 6 return "no negative elements; else return arr.indexOf(arr[i] Validate solution Submit Looks like your solution has mistakes. The indexOfFirstNegative function has been created The function returns the correct result for the argument (1.-2.7]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!