Reputation: 89
I have a function, functionOne, defined normally, outside of other functions or if statements. Now I have another function, functionTwo, and I call functionOne inside of functionTwo. I've tried searching around but I could only find things that told me to define functionOne inside of functionTwo. My issue is that it's already defined, outside of any functions, as I said before.
Here's my code:
function functionOne (connection) {
//code here for functionOne
}
function functionTwo (functionOne, connection) {
//some code here for functionTwo
functionOne(connection)
}
The error is that the connection
var isn't being passed over. Any fixes appreciated! Thanks :)
Upvotes: 0
Views: 187
Reputation: 36
If I am understanding your question you just need to provide the argument(s) for the first function within in the second
function funcOne(a){
return a
}
function funcTwo(b, c){
//funcTwo's value of "b" will be used for funcOne as the "a" argument
return funcOne(b) + c
}
console.log(funcTwo(3,4)) //returns 7
Upvotes: 0
Reputation: 1416
to define a function you should use this syntax:
function funcName(args){
//code
}
here in your example you did not define any function. you just called functions that don't exist.
Upvotes: 1