Tell us what’s happening:
Describe your issue in detail here.
Your code so far
// Only change code below this line
const increment = (number,5
) => 6 + value;
// Only change code above this line
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36 Edg/107.0.1418.52
Challenge: ES6 - Set Default Parameters for Your Functions
Link to the challenge:
hbar1st
2
Hi, welcome to the forum!
We see you have posted some code but did you have a question?
lasjorg
3
Function parameters are variables. You can not hardcode values in their place as you can tell from the syntax error.
The result of increment(5, 2)
should be 7
.
If increment
is given two arguments it will use the values as passed to the function.
The result of increment(5)
should be 6
.
If increment
is given one argument it will use that value as passed to the function and the default value assigned to the value
parameter.
function testArgs(argValueOrUndefined, argValueOrOne = 1) {
console.log(argValueOrUndefined); // undefined
console.log(argValueOrOne); // 1
}
testArgs(); // no arguments
system
Closed
4
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.