You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
13 lines
318 B
TypeScript
13 lines
318 B
TypeScript
// We want to create a function that will add numbers together when called in succession.
|
|
|
|
export default function add(x: number): any {
|
|
const fn = (y: number) => add(x + y);
|
|
fn.valueOf = () => x;
|
|
return fn;
|
|
}
|
|
|
|
const seven = add(1)(2)(4);
|
|
console.log(seven == 7, 'expect 7')
|
|
|
|
console.log(+add(1)(2), 'expect 3')
|