Tell us what’s happening:
Hello everyone kindly guide me out with this challenge.
Your code so far
function functionWithArgs(1,2) {
console.log(1+2);
}
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4.1 Safari/605.1.15
Challenge Information:
Basic JavaScript - Passing Values to Functions with Arguments
Please don’t forget to talk to us about how the instructions or error message is confusing. Communication is a critical coding skill
how do I create a function that accepts two arguments?
Here is a function with two parameters, param1
and param2
:
function testFun(param1, param2) {
console.log(param1, param2);
}
thanks. so how do I create a functionWithArgs(1,2) should output 3
?
You cannot really " create a functionWithArgs(1,2) should output 3
?"
You can’t mix together sentences in the instructions like that.
Create a function called functionWithArgs that accepts two arguments and outputs their sum to the dev console.
Call the function with two numbers as arguments.
Creating and calling the function are two separate instructions
that was the instruction?
No, it was not. You cannot mix together the sentences like that.
The test said only
functionWithArgs(1,2) should output 3.
Creating a function and calling a function are different things.
And this was not an instruction. You mixed together two sentences in a way that doesn’t work.
This here is an example of creating a function.
function functionWithArgs(1 + 2) {
console.log(1 + 2);
}
function functionWithArgs(7 + 9) {
console.log(7 + 9);
}
functionWithArgs
Above is what I was able to come up with.
Did this example of creating a function use numbers? nope, it didn’t!
function functionWithArgs(one, two) {
console.log(one, two);
}
function functionWithArgs(seven, nine) {
console.log(seven, nine);
}
functionWithArgs
Done this but still not successful
Now the issue is that you defined the function twice. You must only have one function definition
function functionWithArgs(one, two) {
console.log(seven, nine);
}
functionWithArgs
Kindly be patient with me mate. I can do this, I believe.
This is a single function definition, but you have to use the function parameters ‘one’ and ‘two’. The variables ‘seven’ and ‘nine’ are not defined
firstly, how do I use the function parameters ‘one’ and ‘two’ and how do I define the variables ‘seven’ and ‘nine’?
You should not definite the variables ‘seven’ and ‘nine’. You should not use the variables ‘seven’ and ‘nine’ at all.
function functionWithArgs(one, two) {
console.log(one, two);
}
functionWithArgs
Closer, the function definition looks ok. But you aren’t calling the function correctly