Wednesday, November 16, 2016

DeMorgans Problem

// Write a function or that works like ||, but only uses ! and &&.

// Write a function OR that takes two Boolean values and returns 
// a Boolean value such that it is not true that both are false
// ... i.e., one or the other or both 

function OR(val1, val2) {
  return !(!val1 && !val2); 
}
function testDeMorgans(val1, val2) {
  return (val1 || val2) === OR(val1, val2);
}
testDeMorgans(true, true); // returns true meaning OR function === ||
testDeMorgans(true, false); 
testDeMorgans(false, false);