I have a javascript coding exercise to do which has got me a bit stuck (I'm only just starting javascript).
The exercise is as follows:
Write a function multiply(a) that returns a function capable of multiplying by a. Call this function with b as a parameter.
So far I have the main skeleton (not difficult):
function multiply(a) {
return //Stuck here
}
I'm not sure if the question is to call multiply(b) and have it give us the result of a*b or something else...
I tried writing a function directly after the return statement but this just printed out the function name.
function multiply(a) {
return function f { return a * b } //Here I assume b is a variable defined somewhere
}
Thanks in advance!