Tell us what’s happening:
// tests completed
this is what my dev console is showing
any help is welcomed```
**Your code so far**
```js
// Example
function ourFunctionWithArgs(a, b) {
console.log(a - b);
}
ourFunctionWithArgs(10, 5); // Outputs 5
// Only change code below this line.
function functionWithArgs(a, b) {
console.log(1 + 2);
console.log(7 + 9);
}
functionWithArgs(1, 2);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/passing-values-to-functions-with-arguments
Look at the example code:
function ourFunctionWithArgs(a, b) {
console.log(a - b);
}
You need to use the parameters (a
and b
), not hardcoded numbers.
Did you figure it out?
Here is another example of two different functions, one is static with hard-coded values, the other is dynamic using parameters/arguments.
// Function has no parameters, just logs a hard-coded string
function hardCodedGreeting() {
console.log('Hello, Jack');
}
// No arguments passed when calling the function
hardCodedGreeting();
// Hello, Jack
// Function has two parameters used to construct the string
function dynamicGreeting(greeting, name) {
console.log(greeting + ', ' + name);
}
// Two arguments passed when calling the function
dynamicGreeting('Wassup', 'John');
// Wassup, John
dynamicGreeting('Good day', 'Alice');
// Good day, Alice