compare equality function

this will check if two values are exactly equal

Demo

function is_equal(a, b) {
  if (a === b) {
    return "Equal";
  }
  return "Not Equal";
}
console.log(is_equal(1,1));
console.log(is_equal(1,'1'));

// you can also change this function to return true and false, but this may be just as long as actually doing the if(a === b) manually.
function is_equal_bool(a, b) {
  if (a === b) {
    return true;
  }
  return false;
}

if(is_equal_bool(1, 1)) {
  console.log('1 and 1 is exactly equal');
}

// vs -- probably better to just use the ===
if( 1 === 1 ) {
  console.log('1 and 1 is exactly equal');
} else {
  console.log('1 and 1 is NOT exactly equal');
}

Welcome

This is my test area for webdev. I keep a collection of code snippits here, mostly for my reference. Also if i find a good site, i usually add it here.

❤👩‍💻🕹