Closure/Не знаю как написать функцию с замыканием
- Write add function which consumes x as argument (number) and returned other function which consumes y as argument (number)
- and return the sum of x and y
function foo() {
function add(x) {
}} // Upgrade this function
- should summarize two values using closure
- should sum 3 and 5
should sum 4 and 2
should sum 9 and -2
Ответы (1 шт):
Автор решения: ClickName
→ Ссылка
function add(x) {
function other(y) {
return x+y;
}
return other;
}