Computer scienceProgramming languagesJavaScriptWorking with dataArrays

Array iterating

Three

Report a typo

The given function receives an integer array. Return an index of the first element that has the value 3. If there is no such value, return -1.

Sample Input 1:

[ 1, 2, 3 ]

Sample Output 1:

2

Sample Input 2:

[ 0, 3, 3, 2 ]

Sample Output 2:

1

Sample Input 3:

[ 1, 13, 4, 0 ]

Sample Output 3:

-1
Write a program in JavaScript
function three(arr) {
//write your code here
}
___

Create a free account to access the full topic