So I'm using Kahn academy but it keeps saying I have bad invocation in {guess = 3((max + min) / 2);} right before the three. I am not sure what I'm doing wrong can someone help? (this is using JavaScript) Please help? i will give good points and brainliest.

The instructions given were:
1. Let min = 0 and max = n-1.
2. If max < min, then stop: target is not present in array. Return -1.
3. Compute guess as the average of max and min, rounded down (so that it is an integer).
4. If array[guess] equals target, then stop. You found it! Return guess.
5. If the guess was too low, that is, array[guess] < target, then set min = guess + 1.
6. Otherwise, the guess was too high. Set max = guess - 1.
7. Go back to step 2.


/* Returns either the index of the location in the array,
or -1 if the array did not contain the targetValue */
var min = 0;
var max = array.length - 1;
var guess;
while (min < max) {
guess = 3((max + min) / 2);
if (array[guess] === targetValue) {
return guess;
} else if (array[guess] < targetValue) {
min = guess - 1;
} else {
max = guess + 1;
}
}
return -1;
};
var primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97];
var result = doSearch(primes, 73);
console.log("Found prime at index " + result);
//print (primes[]);
//Program.assertEqual(doSearch(primes, 73), 20);



Answer :

tonb

The 3 isn't supposed to be there. What did you think it was doing?

Also, I miss the function header, ie something like:

function guessNumber(array, targetValue) {

and finally, you swapped the guess-1 and guess+1. It says when the array value at array[guess] is lower than the targetValue, you should set min to guess+1 (ie., look further, not look back).