Values to Functions with Arguments

Values to Functions with Arguments
0

#1

Tell us what’s happening:

What am i doing wrong?!? I can’t for the life of me figure this one out…help!!

Your code so far

// Example
function ourFunctionWithArgs(a, b) {
  console.log(a - b);
}
ourFunctionWithArgs(10, 5); // Outputs 5

// Only change code below this line.
function testFun(a, b) {
  console.log(a - b);
}
ourFunctionWithArgs(1,2);

ourFunctionWithArgs(7,9);```
**Your browser information:**

Your Browser User Agent is: ```Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36```.

**Link to the challenge:**
https://www.freecodecamp.org/challenges/passing-values-to-functions-with-arguments

#2

What do the failing tests say?

It doesn’t look like you actually ever call the function testFun


#3
// Example
function ourFunctionWithArgs(a, b) {
  console.log(a - b);
}
ourFunctionWithArgs(10, 5); // Outputs 5

// Only change code below this line.
function testFun(a, b) {
  console.log(a - b);
}
ourFunctionWithArgs(1,2);

ourFunctionWithArgs(7,9);

so is it this but instead of ourFunctionWith Args it should be testFun? so confused


#4

I’ve edited your post for readability. When you enter a code block into the forum, precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.


#5

ourFunctionWithArgs(1,2) will run the example function ourFunctionWithArgs with the arguments 1 and 2.
If you want to run the function testFun, then you need to call it.


#6

this still is not making any sense

‘’’
// Example
function ourFunctionWithArgs(a, b) {
console.log(a - b);
}
ourFunctionWithArgs(10, 5); // Outputs 5

// Only change code below this line.
function ourFunctionWithArgs(a, b) {
console.log( - b);
}
ourFunctionWithArgs(1,2);

ourFunctionWithArgs(7,9);

ourFuntionWithArgs();
‘’’
first one is checked off, the rest and marked wrong what am i doing wrong???


#7

Why did you change the name of your function?


#8

because neither one was showing up right…
can this be explained in the simplest of terms so i can understand it?
How did you pass this one?


#9

Functions have names. Functions only run when you call them using their names.

function theFunctionName(whatever) {
    whatever
}

doesn’t do anything unless you call it

theFunctionName(something);