Logical Operators

hey guys. I need some help with some OR and XOR operators.

For OR, I am trying to get 0 1 = 1. My code works for other options but not this one.

 if(a === 0 || b === 1) {
   return a;
 } else if (b === 1 || a === 1) {
   return a;
 } else
 return b - a;
}

I am also trying to get the results 0 0 = 1, 1 0 = 1 and 1 1 = 0

function nor(a, b) {
  if(a !== 0 || b !== 0) {
    return a;
  }else if(a !== 1 || b !== 0) {
    return a;
  }else{
    return b;
  }


}

Any help is appreciated!

I think what you are doing on the first logic is basically this:

   if(a === 0 || b === 1 || a === 1) {
   return a;
   }
  else{
  return b - a;
  }

Your function stops running as soon as your a equals zero, regardless of the value of b. That’s why you always get returned 0 when you pass 01. You need to accound for a===0 && b===1 to return b. And I think it is a similar case with the negated function.