Describe your problem and how to reproduce it:
The usage of the word "argument" ist unclear to me. The title of this challenge uses the word "parameter".
Then the instructions state:
"If an arrow function has a single argument, the parentheses enclosing the argument may be omitted."
But the following snippet cited from the instructions shows the parameter "item" without parentheses:
// the same function, without the argument [sic] parentheses
const doubler = item => item * 2;
The functions are never invoked with an argument in the examples.
As I understand it the sentence should say: "If an arrow function has a single parameter, the parentheses enclosing the parameter may be omitted."
Add a Link to the page with the problem:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/es6/write-arrow-functions-with-parameters
or,
Tell us about your browser and operating system:
If possible, add a screenshot here (you can drag and drop, png, jpg, gif, etc. in this box):
Hello~!
I agree that the verbiage is wrong here. Argument
should probably be replaced with parameter
in the examples and text, with the exception of the top line (which, at a quick glance, is the only correct use of argument
):
Just like a regular function, you can pass arguments into an arrow function.
If an arrow function has a single argument, the parentheses enclosing the argument may be omitted.
// the same function, without the argument parentheses
const doubler = item => item * 2;
These are the ones that should be changed, I think. In fact, we could use
// the same function, without the parentheses
const doubler = item => item * 2;
instead.
I like that approach. Think this could be opened up to first timers?
I would go for:
Just like a regular function, you can pass arguments into an arrow function.
// doubles input value and returns it
const doubler = (item) => item * 2;
doubler(4); // returns 8
If an arrow function has a single parameter, the parentheses enclosing the parameter may be omitted.
// the same function, without the parameter parentheses
const doubler = item => item * 2;
It is possible to pass more than one argument into an arrow function.
// multiplies the first input value by the second and returns it
const multiplier = (item, multi) => item * multi;
multiplier(4, 2); // returns 8
Sure, that works.