Hacker News new | ask | show | jobs
by benburton 1958 days ago
const add = ({ a, b }) => a + b; const _add = ({ a, b }) => b + a;
1 comments

That one is rather simple to break.

    console.log(add({a:"1", b:2})) //12
    console.log(_add({a:"1", b:2})) //21
So to make the code break with the change to _add, I can just do:

    if(add({a:"1", b:2}) != 12) boom()
Ah of course!