Tell us what’s happening:
I can’t solve this. Im highly sure that i don’t get what is said in the instructions.
can you tell me in an easy way?
Your code so far
function functionWithArgs(a){
console.log(1 + 2);
}
function functionWithArgs(a){
console.log(7 + 9);
}
functionWithArgs(a);
functionWithArgs(b);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0
Challenge Information:
Basic JavaScript - Passing Values to Functions with Arguments
zaklina
November 21, 2023, 10:55am
2
you’ve declared the function functionWithArgs twice with the same name
Create a function called functionWithArgs that accepts two arguments and outputs their sum to the dev console.
function functionWithArgs(a, b)
then in the console.log put a+b …
I changed the code to this. But still not working.
function functionWithArgs(1,2){
console.log(1 + 2);
}
functionWithArgs(1,2);
function functionWithArgs(7,9){
console.log(7 + 9);
}
functionWithArgs(b);
zaklina
November 21, 2023, 11:00am
4
you have two functions with the same name, you need only one
so how do i do it? can i put two console.log inside the same function? and am i supposed to use a and b to set.
like a = 1 +2 etc.
zaklina
November 21, 2023, 11:03am
6
delete one function ,you should have only one
Deleted! Now it looks like this
function functionWithArgs(1,2) {
console.log(1 + 2);
}
zaklina
November 21, 2023, 11:05am
8
cal you function in the end
zaklina
November 21, 2023, 11:09am
10
insted of 1 and 2 add a and b in the function and in the consol
but leve the numbers in the coling function
zaklina
November 21, 2023, 11:13am
12
yes you have a single function functionWithArgs that takes two parameters (a and b ) and logs the sum of these parameters. When you call the function with specific numbers, it will output the correct sum to the console.
But this won’t work isnt it? cause i havent declared any values for a and b.
edit: no it worked!!!
It’s good that you solved the challenge, however, the forum does not allow the direct posting of solutions. I am going to edit your reply and remove the solution.
Thank you so much @zaklina .It worked
Okay…I’m sorry i did’nt know that. I’m New to the Forrum
zaklina
November 21, 2023, 11:20am
17
Happy coding… glad to help…
No worries.
Keep up the good progress.