Concepts
Linear search
Sequentially check values with a specified equality rule; stop at the first match or return the documented absent sentinel.
Formal Syntax & Structure
javascript syntaxjavascript
findFirst(values, target) → index | -1Working Example
Example Snippetjavascript
function findFirst(values, target) { for (let i = 0; i < values.length; i++) { if (values[i] === target) return i; } return -1;}console.log(findFirst([8, 3, 8], 8), findFirst([8, 3], 9));