Array Includes in JavaScript

Level 283 keystrokes

includes() checks if an array contains a specific element and returns a boolean.

JavaScript code

// Create an array of fruit names
1let fruits = ["apple", "banana", "orange"];
// includes() searches the array for "banana"
// Returns true because "banana" exists in the array
2console.log(fruits.includes("banana"));

Output

true
Practice typing this code

Practice typing this code. Results are not recorded in the rankings.

Symbols in this code

The symbols you type in this JavaScript code and how often they appear.

  • "× 8
  • ,× 2
  • ;× 2
  • .× 2
  • (× 2
  • )× 2
  • [× 1
  • ]× 1
  • =× 1

More JavaScript examples at level 2

← JavaScript typing practice