Tried to use curry function to write if condition (without "if" "true" and "false"). Have no idea how to do it right! Can anyone help and show me how to do it?
const True = () => {};
const False = () => {};
const If = True => False => ifFunction(True)(False);
const ifFunction = If(True);
ifFunction('1')('2'); // 1
console.log(If(True)('1')('2')); // 1
console.log(If(False)('1')('2')); // 2
It should return 1 or 2 depends on which function is getting pass to if condition. But this code does not work at all.
ifElsewhich implementsifElse(conditionFn, trueBranchFn, falseBranchFn). The library uses a simple conditional operator as the implementation (simplified):conditionFn() ? trueBranchFn() : falseBranchFn()