Read the question, write TypeScript on the right, then Run or Check.
QuestionHint and solution stay closed until you open them
First line: space-separated integers. Second line: target. Print the 0-based index of the first match, or -1.
Input. Two lines.
Output. Index or -1.
Examples
Input
4 8 15 16 15
Output
2
Input
1 2 3 9
Output
-1
Hint
- indexOf(target)
Show correct code
Peek only after you have tried. You can still Check your own version.
const nums = readLine().trim().split(/\s+/).map(Number);
const target = Number(readLine());
console.log(nums.indexOf(target));
main.tstsc · readLine() · Ctrl + Enter
ResultIdle
Run to see output. Check grades the tests.