The ticket-scan demo stopped at the first matching ID. Apply the same search to guesses in findGuess(secret, guesses), returning a match message immediately. If the loop ends without a match, return "No match". Keep all work in script.js and log each checkpoint separately.
A loop can return as soon as it finds the first matching item:
function firstEven(values) {
for (const value of values) {
if (value % 2 === 0) return value;
}
return null;
}
console.log(firstEven([3, 8, 10])); // 8
findGuess(secret, guesses) to return "Correct: <number>" on the first match or "No match" if none matches. The provided first-guess probe should print First guess: Correct: 2.Match: Correct: 7 from (7, [3,9,7,7]).Missing: No match from (7, [1,2,3]).Correct: 7 alone from (7, [3,9,7]).Run after each change; the Console should show four separate checkpoint lines.
Start with the smallest function signature, then test one case at a time.