Right. Let’s break your assignment point by point:
- functionWithArgs should be a function.
Here you have it right, you simply need to define a function, let’s do this:
function functionWithArgs() {
//nothing here yet
};
- functionWithArgs should output 3.
This tells us, clearly, that our function should take two arguments, because we have (1,2) part, so let’s expand on our first example above:
function functionWithArgs(a,b) {
// nothing here yet
};
In addition to this, it also tells us what the output should be. Instead of thinking about it now, let’s move to 3rd point that will help us see the pattern.
- functionWithArgs(7,9) should output 16.
And here we stop for a moment. Take a look at points 2 and 3. This is the same function (have the same name, additionally same number of parameters). What do they have in common? If we think of a very simple operations, you can notice that the output of this function is nothing else, but a simple addition of arguments:
1 + 2 = 3
7 + 9 = 16
So, what should you do now? You should define body of your function to do just that.
I am not sure what’s the context of this task / assignment (the last point confuses me), but your functionWithArgs(a,b) should either return or print (console.log()) your function output.
function functionWithArgs(a, b) {
// here you place your function body, e.g. console.log(a);
};
// and here we call this function with parameters a = 1, b = 2, which should output 3
functionWithArgs(1,2);
Hope this makes it a bit easier to understand now?