4 ms·
You swapped the order of method arguments though you are doing x add Sy which isn't the same as Sy add x Number.prototype.add = function (y) {
by jjaredsimpson 8y ago
You swapped the order of method arguments though
you are doing x add Sy which isn't the same as Sy add x
Number.prototype.add = function (y) {
var x = Number(this)
return x===0 ? y : (y+1).add(x-1)
}
console.log(Number(3).add(2)) // infinite
- quietbritishjim 8y agoOops, sorry, I see what you mean now. You're right, it looks like this is a mistake: S: innerX => S(y).add(innerX) It should be S: innerX => S(innerX).add(y)