Reputation: 31
first = function firstFunction(arg1){
return arg1;
}
second = function secondFunction(arg2){
return arg2;
}
final = function secondFunction(first, second ){
return first + second;
}
first(10);
second(20);
final(first, second);
I wrote this code and here's what I understand of it. Got three function first two return a value. first has the value it returned and second the same.
Now the third one is using two parameters, first and second. According to me first argument has value of 10 and second 20.
The third function is suppose to return first + second which is 30. But instead it returns this:
"function firstFunction(arg1){
return arg1;
}function secondFunction(arg2){
return arg2;
}"
Help, please
Upvotes: 0
Views: 253
Reputation: 1
function One(arg1){
return arg1;
}
function Two(arg2){
return arg2;
}
function Three(arg1, arg2){
return arg1 + arg2;
}
let first = One(5);
let second = Two(5);
console.log( Three(first , second) );
Upvotes: 0
Reputation: 183
You did not give the value as a parameter but you gave the functions itself. Try something like this:
final(first(10), second(20));
Another way to go:
var a = first(10);
var b = second(20);
final(a, b);
Upvotes: 1