const zero = f => x => x;
const one = f => x => f(x);
const two = f => x => f(f(x));
const thr = f => x => f(f(f(x)));
const add =
m => n => f => x =>
m(f)(n(f)(x));
const toNumber = n => n(x => x + 1)(0);
console.log(toNumber(add(thr)(two))); // 3
To embed this project on your website, copy the following code and paste it into your website's HTML: