Check if Variable Doesn't Equal Multiple Values in JS-Code Examples

Radu TM

Check if Variable Doesn't Equal Multiple Values in JS

JavaScript by Radu TM June 21, 2022

let val = "😃"

// check if val doesn't equal "😐" or "😶"
if (val !== "😐" && val !== "😶") {
  console.log("val is not a neutral emoji!")
}

0

29.865

Check if Variable Doesn't Equal Multiple Values in JS

JavaScript by Radu TM June 21, 2022

const animal = '😋'

if (!['🐶', '🐱', '🐭'].includes(animal)) {
  console.log('not a pet');
} else {
  console.log('is a pet');
}

0

29.865

Check if Variable Doesn't Equal Multiple Values in JS

JavaScript by Radu TM June 21, 2022

//check if variable doesn't equal multiple values
let val = "😋";

if (val !== "🍎" && val !== "🍌" && val !== "🍊") {
  console.log(`${val} is not an emoji for a fruit!`);
}

0

29.865

Check if Variable is equal to Multiple Values in JavaScript

JavaScript by Radu TM June 22, 2022

// check if a variable is equal to multiple values

const value = '🍎';

if (value === '🍎' || value === '🍌' || value === '🍇') {
  console.log('The value is either an apple, a banana, or a grape.');
}

0

11.269

Related JavaScript Queries

Latest JavaScript Queries

Explore code examples by categories