mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-03-04 08:05:48 -05:00
fix(curriculum): correct explanation about arrow functions and update hint text (#58490)
Co-authored-by: Sem Bauke <sem@freecodecamp.org> Co-authored-by: Tom <20648924+moT01@users.noreply.github.com>
This commit is contained in:
@@ -17,7 +17,7 @@ Here is the basic syntax:
|
||||
() => {}
|
||||
```
|
||||
|
||||
To create a named arrow function, you can assign the function to a variable:
|
||||
By assigning the arrow function definition to a variable, you bind it to an identifier.
|
||||
|
||||
```js
|
||||
const exampleFunction = () => {
|
||||
@@ -25,23 +25,23 @@ const exampleFunction = () => {
|
||||
}
|
||||
```
|
||||
|
||||
Create a new named arrow function called `printGreeting`. Inside the body of that function use the `console.log()` method to print the string `"Hello there!"`.
|
||||
Create a new arrow function and assign it to the variable `printGreeting`. Inside the function body, use the `console.log()` method to print the string `Hello there!`.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should have a function called `printGreeting`.
|
||||
You should have a variable named `printGreeting` and assign it an arrow function.
|
||||
|
||||
```js
|
||||
assert.isFunction(printGreeting);
|
||||
```
|
||||
|
||||
You should use arrow syntax to create the `printGreeting` function.
|
||||
You should create an arrow function and assign it to the `printGreeting` variable.
|
||||
|
||||
```js
|
||||
assert.match(code, /(let|const)\s+printGreeting\s*=\s*\(.*\)\s*=>\s*{\s*[\s\S]*}\s*;?/)
|
||||
```
|
||||
|
||||
Your `printGreeting` function should include a `console.log('Hello there!')`.
|
||||
Your `printGreeting` function should log `Hello there!` to the console.
|
||||
|
||||
```js
|
||||
assert.match(printGreeting.toString(), /console\.log\(['"]Hello\s+there!['"]\)/);
|
||||
|
||||
Reference in New Issue
Block a user