To debug the issue with the findIt
function, you should include the variable ar[i]
in a debugging statement before the return statement to understand what value is being compared and why the function is returning that particular index.
By adding a debug print statement for ar[i]
, you can see the elements of the array being checked against x
, which will help you identify why the output is 1 for the number 24 instead of the expected 0.
So the correct answer is:
ar[i]