Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Boolean Algebra by mortonfox
"use strict";
const OPERATIONS = {
conjunction: (x, y) => x & y,
disjunction: (x, y) => x | y,
implication: (x, y) => y ? 1 : x ? 0 : 1,
exclusive: (x, y) => x ^ y,
equivalence: (x, y) => +(x === y)
}
function boolean(x, y, operation) {
return OPERATIONS[operation](x, y);
}
// var assert = require('assert');
// if (!global.is_checking) {
// assert.equal(boolean(1, 0, "conjunction"), 0)
// assert.equal(boolean(1, 0, "disjunction"), 1)
// assert.equal(boolean(1, 1, "implication"), 1)
// assert.equal(boolean(0, 1, "exclusive"), 1)
// assert.equal(boolean(0, 1, "equivalence"), 0)
// console.log("Coding complete? Click 'Check' to review your tests and earn cool rewards!");
// }
May 7, 2020
Comments: