Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
function add(a) {
const sum = b => add (a + b);
sum.valueOf = () => a;
total return;
}
Example:
___ const addTwo = add (2) // sum = (b) => 2 + b; Returns sum function with sum.valueOf = () => 2;
|
|__ addTwo + 5 // 7 sum.valueOf ran when doing math and returned 2 so 2 + 5 = 7;
|
|__ addTwo + add(1) // 3 Both sum.valueOf of the two sum functions ran and returned 2 and 1 so 2 + 1 = 3
___ addTwo(3) // sum = () => 5 + b; Returns sum function with sum.valueOf = () => 5;
|
|__ addTwo(3) == 5 // true Because sum.valueOf ran when you compare with "==" and returned 5 so 5 == 5 is true;
Am I wrong?
Good job!