Searching an array with includes and indexOf
Array method that gives true if the value is in the array, otherwise false. Its partner indexOf(value) gives the position, or -1 if the value is not found.
Understanding Searching an array with includes and indexOf in ACARA Digital Technologies Years 9–10
What it does: includes gives true or false, so it can be used directly as the if condition. indexOf gives -1 when the value is missing, so comparing with -1 tells you it was not found. -1 means not found. 0 would mean the value is the first item in the array. indexOf() returns the index of the first matching item. If there is no match it returns -1.
Common mistakes: indexOf gives -1 when the value is not found, not 0 (0 is the first position). The check should be i === -1. The method is called includes, with an s on the end. include is not an array method and causes a TypeError.
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 710–727) and word search (Modules 710–742).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
includes(value)Fill in the Blanks
Spot the Error
Student with a class code? Join your class →