Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function XOR(a, b) {
- return ((!a && b) || (a && !b));
- }
- function AND(a, b) {
- return (a && b);
- }
- function OR(a, b) {
- return (a || b);
- }
- function logicalCalc(array, operator) {
- boolOperators = {
- 'AND': AND,
- 'OR': OR,
- 'XOR': XOR
- }
- let result = array[0];
- for (let i = 1; i < array.length; i++) {
- result = boolOperators[operator](result, array[i])
- }
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment