Check if Array Doesn't include a Value in JavaScript-Code Examples

Radu TM

Check if Array Doesn't include a Value in JavaScript

JavaScript by Radu TM June 21, 2022

const arr = ['🍎', '🍌', '🍇', '🍈'];

// check if array doesn't include '🍐'
if (!arr.includes('🍐')) {
  console.log("🍐 is not in the array");
} else {
  console.log("🍐 is in the array");
}

0

23.169

Check if Array Doesn't include a Value in JavaScript

JavaScript by Radu TM June 21, 2022

const array = [1, 2, 3, 4, 5];

// checks if array doesn't include 3
if (!array.includes(3)) {
  console.log("array does not include 3");
}

0

23.169

Related JavaScript Queries

Latest JavaScript Queries

Explore code examples by categories