chore(learn): audit javascript algorithms and data structures (#41092)

* chore(learn): audit basic algorithm scripting

* chore(learn): audit basic data structures

* chore(learn): audit basic javascript

* chore(learn): audit debugging

* chore(learn): audit es6

* chore(learn): audit functional programming

* chore(learn): audit intermidate algorithms

* chore(learn): audit js projects

* chore(learn): audit object oriented programming

* chore(learn): audit regex

* fix(learn): remove stray .

* fix(learn): string to code

* fix(learn): missed some

* fix(learn): clarify strings

Based on Randy's feedback, clarifies string instances where quotes
were removed in favour of back ticks.

* fix: apply suggestions - thanks Randy! :)

Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com>

* fix: non-suggestion comments

* chore(learn): remove comments from codes

Removes the comments from the description and instruction code
blocks to ensure that all relevant information is translatable.

* fix: Apply suggestions from code review

Co-authored-by: Shaun Hamilton <51722130+ShaunSHamilton@users.noreply.github.com>

* fix: revert crowdin fix

* Update curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-algorithm-scripting/mutations.md

Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com>

* fix: Apply suggestions from code review

Co-authored-by: Shaun Hamilton <51722130+ShaunSHamilton@users.noreply.github.com>

* Update curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-arrays.md

Co-authored-by: Shaun Hamilton <51722130+ShaunSHamilton@users.noreply.github.com>

* fix: Apply suggestions from code review

Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
Co-authored-by: Shaun Hamilton <51722130+ShaunSHamilton@users.noreply.github.com>

* chore: change voice

* fix: Christopher Nolan

* fix: expressions would evaluate

* fix: will -> would

* Update curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/add-methods-after-inheritance.md

Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com>

* fix: to work to push

* Update curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/iterate-with-javascript-for-loops.md

Co-authored-by: Shaun Hamilton <51722130+ShaunSHamilton@users.noreply.github.com>

* Update curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/add-methods-after-inheritance.md

Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com>

Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com>
Co-authored-by: Shaun Hamilton <51722130+ShaunSHamilton@users.noreply.github.com>
Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
This commit is contained in:
Nicholas Carrigan (he/him)
2021-03-02 16:12:12 -08:00
committed by GitHub
parent 57f3c80345
commit 7117919d36
226 changed files with 1236 additions and 1077 deletions

View File

@ -20,11 +20,11 @@ for (var i = 0; i < 3; i++) {
numArray.push(i);
}
console.log(numArray);
// returns [0, 1, 2]
console.log(i);
// returns 3
```
Here the console will display the values `[0, 1, 2]` and `3`.
With the `var` keyword, `i` is declared globally. So when `i++` is executed, it updates the global variable. This code is similar to the following:
```js
@ -34,12 +34,12 @@ for (i = 0; i < 3; i++) {
numArray.push(i);
}
console.log(numArray);
// returns [0, 1, 2]
console.log(i);
// returns 3
```
This behavior will cause problems if you were to create a function and store it for later use inside a for loop that uses the `i` variable. This is because the stored function will always refer to the value of the updated global `i` variable.
Here the console will display the values `[0, 1, 2]` and `3`.
This behavior will cause problems if you were to create a function and store it for later use inside a `for` loop that uses the `i` variable. This is because the stored function will always refer to the value of the updated global `i` variable.
```js
var printNumTwo;
@ -51,9 +51,10 @@ for (var i = 0; i < 3; i++) {
}
}
console.log(printNumTwo());
// returns 3
```
Here the console will display the value `3`.
As you can see, `printNumTwo()` prints 3 and not 2. This is because the value assigned to `i` was updated and the `printNumTwo()` returns the global `i` and not the value `i` had when the function was created in the for loop. The `let` keyword does not follow this behavior:
```js
@ -66,16 +67,16 @@ for (let i = 0; i < 3; i++) {
}
}
console.log(printNumTwo());
// returns 2
console.log(i);
// returns "i is not defined"
```
`i` is not defined because it was not declared in the global scope. It is only declared within the for loop statement. `printNumTwo()` returned the correct value because three different `i` variables with unique values (0, 1, and 2) were created by the `let` keyword within the loop statement.
Here the console will display the value `2`, and an error that `i is not defined`.
`i` is not defined because it was not declared in the global scope. It is only declared within the `for` loop statement. `printNumTwo()` returned the correct value because three different `i` variables with unique values (0, 1, and 2) were created by the `let` keyword within the loop statement.
# --instructions--
Fix the code so that `i` declared in the if statement is a separate variable than `i` declared in the first line of the function. Be certain not to use the `var` keyword anywhere in your code.
Fix the code so that `i` declared in the `if` statement is a separate variable than `i` declared in the first line of the function. Be certain not to use the `var` keyword anywhere in your code.
This exercise is designed to illustrate the difference between how `var` and `let` keywords assign scope to the declared variable. When programming a function similar to the one used in this exercise, it is often better to use different variable names to avoid confusion.
@ -87,7 +88,7 @@ This exercise is designed to illustrate the difference between how `var` and `le
(getUserInput) => assert(!getUserInput('index').match(/var/g));
```
The variable `i` declared in the if statement should equal "block scope".
The variable `i` declared in the `if` statement should equal the string `block scope`.
```js
(getUserInput) =>
@ -96,7 +97,7 @@ The variable `i` declared in the if statement should equal "block scope".
);
```
`checkScope()` should return "function scope"
`checkScope()` should return the string `function scope`
```js
assert(checkScope() === 'function scope');

View File

@ -8,7 +8,7 @@ dashedName: create-a-module-script
# --description--
JavaScript started with a small role to play on an otherwise mostly HTML web. Today, its huge, and some websites are built almost entirely with JavaScript. In order to make JavaScript more modular, clean, and maintainable; ES6 introduced a way to easily share code among JavaScript files. This involves exporting parts of a file for use in one or more other files, and importing the parts you need, where you need them. In order to take advantage of this functionality, you need to create a script in your HTML document with a type of `module`. Heres an example:
JavaScript started with a small role to play on an otherwise mostly HTML web. Today, its huge, and some websites are built almost entirely with JavaScript. In order to make JavaScript more modular, clean, and maintainable; ES6 introduced a way to easily share code among JavaScript files. This involves exporting parts of a file for use in one or more other files, and importing the parts you need, where you need them. In order to take advantage of this functionality, you need to create a script in your HTML document with a `type` of `module`. Heres an example:
```html
<script type="module" src="filename.js"></script>
@ -28,7 +28,7 @@ You should create a `script` tag.
assert(code.match(/<\s*script[^>]*>\s*<\/\s*script\s*>/g));
```
Your `script` tag should be of type `module`.
Your `script` tag should have the `type` attribute with a value of `module`.
```js
assert(

View File

@ -15,17 +15,17 @@ There is another `export` syntax you need to know, known as <dfn>export default<
Below are examples using `export default`:
```js
// named function
export default function add(x, y) {
return x + y;
}
// anonymous function
export default function(x, y) {
return x + y;
}
```
The first is a named function, and the second is an anonymous function.
Since `export default` is used to declare a fallback value for a module or file, you can only have one value be a default export in each module or file. Additionally, you cannot use `export default` with `var`, `let`, or `const`
# --instructions--
@ -34,7 +34,7 @@ The following function should be the fallback value for the module. Please add t
# --hints--
Your code should use `export` fallback.
Your code should use an `export` fallback.
```js
assert(

View File

@ -20,16 +20,14 @@ const person = {
age: 56
};
// Template literal with multi-line and string interpolation
const greeting = `Hello, my name is ${person.name}!
I am ${person.age} years old.`;
console.log(greeting); // prints
// Hello, my name is Zodiac Hasbro!
// I am 56 years old.
console.log(greeting);
```
The console will display the strings `Hello, my name is Zodiac Hasbro!` and `I am 56 years old.`.
A lot of things happened there. Firstly, the example uses backticks (`` ` ``), not quotes (`'` or `"`), to wrap the string. Secondly, notice that the string is multi-line, both in the code and the output. This saves inserting `\n` within strings. The `${variable}` syntax used above is a placeholder. Basically, you won't have to use concatenation with the `+` operator anymore. To add variables to strings, you just drop the variable in a template string and wrap it with `${` and `}`. Similarly, you can include other expressions in your string literal, for example `${a + b}`. This new way of creating strings gives you more flexibility to create robust strings.
# --instructions--

View File

@ -14,9 +14,11 @@ The keyword `let` is not the only new way to declare variables. In ES6, you can
```js
const FAV_PET = "Cats";
FAV_PET = "Dogs"; // returns error
FAV_PET = "Dogs";
```
The console will display an error due to reassigning the value of `FAV_PET`.
As you can see, trying to reassign a variable declared with `const` will throw an error. You should always name variables you don't want to reassign using the `const` keyword. This helps when you accidentally attempt to reassign a variable that is meant to stay constant. A common practice when naming constants is to use all uppercase letters, with words separated by an underscore.
**Note:** It is common for developers to use uppercase variable identifiers for immutable values and lowercase or camelCase for mutable values (objects and arrays). In a later challenge you will see an example of a lowercase variable identifier being used for an array.

View File

@ -14,24 +14,27 @@ One of the biggest problems with declaring variables with the `var` keyword is t
var camper = 'James';
var camper = 'David';
console.log(camper);
// logs 'David'
```
Here the console will display the string `David`.
As you can see in the code above, the `camper` variable is originally declared as `James` and then overridden to be `David`. In a small application, you might not run into this type of problem, but when your code becomes larger, you might accidentally overwrite a variable that you did not intend to overwrite. Because this behavior does not throw an error, searching and fixing bugs becomes more difficult.
A new keyword called `let` was introduced in ES6 to solve this potential issue with the `var` keyword. If you were to replace `var` with `let` in the variable declarations of the code above, the result would be an error.
```js
let camper = 'James';
let camper = 'David'; // throws an error
let camper = 'David';
```
This error can be seen in the console of your browser. So unlike `var`, when using `let`, a variable with the same name can only be declared once. Note the `"use strict"`. This enables Strict Mode, which catches common coding mistakes and "unsafe" actions. For instance:
```js
"use strict";
x = 3.14; // throws an error because x is not declared
x = 3.14;
```
This will display an error that `x is not defined`.
# --instructions--
Update the code so it only uses the `let` keyword.
@ -44,13 +47,13 @@ Update the code so it only uses the `let` keyword.
(getUserInput) => assert(!getUserInput('index').match(/var/g));
```
`catName` should be `Oliver`.
`catName` should be the string `Oliver`.
```js
assert(catName === 'Oliver');
```
`quote` should be `"Oliver says Meow!"`
`quote` should be the string `Oliver says Meow!`
```js
assert(quote === 'Oliver says Meow!');

View File

@ -12,7 +12,7 @@ Promises are most useful when you have a process that takes an unknown amount of
```js
myPromise.then(result => {
// do something with the result.
});
```

View File

@ -12,7 +12,7 @@ dashedName: handle-a-rejected-promise-with-catch
```js
myPromise.catch(error => {
// do something with the error.
});
```

View File

@ -16,11 +16,13 @@ However, it is important to understand that objects (including arrays and functi
```js
const s = [5, 6, 7];
s = [1, 2, 3]; // throws error, trying to assign a const
s[2] = 45; // works just as it would with an array declared with var or let
console.log(s); // returns [5, 6, 45]
s = [1, 2, 3];
s[2] = 45;
console.log(s);
```
`s = [1, 2, 3]` will result in an error. The `console.log` will display the value `[5, 6, 45]`.
As you can see, you can mutate the object `[5, 6, 7]` itself and the variable `s` will still point to the altered array `[5, 6, 45]`. Like all arrays, the array elements in `s` are mutable, but because `const` was used, you cannot use the variable identifier `s` to point to a different array using the assignment operator.
# --instructions--

View File

@ -18,19 +18,20 @@ let obj = {
review:"Awesome"
};
Object.freeze(obj);
obj.review = "bad"; // will be ignored. Mutation not allowed
obj.newProp = "Test"; // will be ignored. Mutation not allowed
obj.review = "bad";
obj.newProp = "Test";
console.log(obj);
// { name: "FreeCodeCamp", review:"Awesome"}
```
The `obj.review` and `obj.newProp` assignments will result in errors, and the console will display the value `{ name: "FreeCodeCamp", review: "Awesome" }`.
# --instructions--
In this challenge you are going to use `Object.freeze` to prevent mathematical constants from changing. You need to freeze the `MATH_CONSTANTS` object so that no one is able to alter the value of `PI`, add, or delete properties.
# --hints--
You should not replace `const` keyword.
You should not replace the `const` keyword.
```js
(getUserInput) => assert(getUserInput('index').match(/const/g));
@ -43,7 +44,7 @@ You should not replace `const` keyword.
assert(getUserInput('index').match(/const\s+MATH_CONSTANTS/g));
```
You should not change original `MATH_CONSTANTS`.
You should not change the original declaration of `MATH_CONSTANTS`.
```js
(getUserInput) =>

View File

@ -15,11 +15,13 @@ Check out this code:
```js
const greeting = (name = "Anonymous") => "Hello " + name;
console.log(greeting("John")); // Hello John
console.log(greeting()); // Hello Anonymous
console.log(greeting("John"));
console.log(greeting());
```
The default parameter kicks in when the argument is not specified (it is undefined). As you can see in the example above, the parameter `name` will receive its default value `"Anonymous"` when you do not provide a value for the parameter. You can add default values for as many parameters as you want.
The console will display the strings `Hello John` and `Hello Anonymous`.
The default parameter kicks in when the argument is not specified (it is undefined). As you can see in the example above, the parameter `name` will receive its default value `Anonymous` when you do not provide a value for the parameter. You can add default values for as many parameters as you want.
# --instructions--

View File

@ -42,7 +42,7 @@ Rewrite the function assigned to the variable `magic` which returns a `new Date(
# --hints--
User should replace `var` keyword.
You should replace the `var` keyword.
```js
(getUserInput) => assert(!getUserInput('index').match(/var/g));
@ -60,13 +60,13 @@ User should replace `var` keyword.
assert(typeof magic === 'function');
```
`magic()` should return correct date.
`magic()` should return the correct date.
```js
assert(magic().setHours(0, 0, 0, 0) === new Date().setHours(0, 0, 0, 0));
```
`function` keyword should not be used.
The `function` keyword should not be used.
```js
(getUserInput) => assert(!getUserInput('index').match(/function/g));

View File

@ -12,7 +12,7 @@ ES6 provides a new syntax to create objects, using the <dfn>class</dfn> keyword.
It should be noted that the `class` syntax is just syntax, and not a full-fledged class-based implementation of an object-oriented paradigm, unlike in languages such as Java, Python, Ruby, etc.
In ES5, we usually define a constructor function and use the `new` keyword to instantiate an object.
In ES5, we usually define a `constructor` function and use the `new` keyword to instantiate an object.
```js
var SpaceShuttle = function(targetPlanet){
@ -21,7 +21,7 @@ var SpaceShuttle = function(targetPlanet){
var zeus = new SpaceShuttle('Jupiter');
```
The `class` syntax simply replaces the constructor function creation:
The `class` syntax simply replaces the `constructor` function creation:
```js
class SpaceShuttle {
@ -32,17 +32,17 @@ class SpaceShuttle {
const zeus = new SpaceShuttle('Jupiter');
```
It should be noted that the `class` keyword declares a new function, to which a constructor is added. This constructor is invoked when `new` is called to create a new object.
**Notes:**
It should be noted that the `class` keyword declares a new function, to which a constructor is added. This constructor is invoked when `new` is called to create a new object.
- UpperCamelCase should be used by convention for ES6 class names, as in `SpaceShuttle` used above.
- The constructor method is a special method for creating and initializing an object created with a class. You will learn more about it in the Object Oriented Programming section of the JavaScript Algorithms And Data Structures Certification.
**Note:** UpperCamelCase should be used by convention for ES6 class names, as in `SpaceShuttle` used above.
The `constructor` method is a special method for creating and initializing an object created with a class. You will learn more about it in the Object Oriented Programming section of the JavaScript Algorithms And Data Structures Certification.
# --instructions--
Use the `class` keyword and write a constructor to create the `Vegetable` class.
Use the `class` keyword and write a `constructor` to create the `Vegetable` class.
The `Vegetable` class allows you to create a vegetable object with a property `name` that gets passed to the constructor.
The `Vegetable` class allows you to create a vegetable object with a property `name` that gets passed to the `constructor`.
# --hints--
@ -54,7 +54,7 @@ assert(
);
```
`class` keyword should be used.
The `class` keyword should be used.
```js
assert(code.match(/class/g));

View File

@ -16,35 +16,39 @@ Destructuring an array lets us do exactly that:
```js
const [a, b] = [1, 2, 3, 4, 5, 6];
console.log(a, b); // 1, 2
console.log(a, b);
```
The console will display the values of `a` and `b` as `1, 2`.
The variable `a` is assigned the first value of the array, and `b` is assigned the second value of the array. We can also access the value at any index in an array with destructuring by using commas to reach the desired index:
```js
const [a, b,,, c] = [1, 2, 3, 4, 5, 6];
console.log(a, b, c); // 1, 2, 5
console.log(a, b, c);
```
The console will display the values of `a`, `b`, and `c` as `1, 2, 5`.
# --instructions--
Use destructuring assignment to swap the values of `a` and `b` so that `a` receives the value stored in `b`, and `b` receives the value stored in `a`.
# --hints--
Value of `a` should be 6, after swapping.
The value of `a` should be `6`, after swapping.
```js
assert(a === 6);
```
Value of `b` should be 8, after swapping.
The value of `b` should be `8`, after swapping.
```js
assert(b === 8);
```
You should use array destructuring to swap a and b.
You should use array destructuring to swap `a` and `b`.
```js
assert(/\[\s*(\w)\s*,\s*(\w)\s*\]\s*=\s*\[\s*\2\s*,\s*\1\s*\]/g.test(code));

View File

@ -20,10 +20,9 @@ Here's how you can give new variable names in the assignment:
```js
const { name: userName, age: userAge } = user;
// userName = 'John Doe', userAge = 34
```
You may read it as "get the value of `user.name` and assign it to a new variable named `userName`" and so on.
You may read it as "get the value of `user.name` and assign it to a new variable named `userName`" and so on. The value of `userName` would be the string `John Doe`, and the value of `userAge` would be the number `34`.
# --instructions--

View File

@ -15,17 +15,20 @@ Consider the following ES5 code:
```js
const user = { name: 'John Doe', age: 34 };
const name = user.name; // name = 'John Doe'
const age = user.age; // age = 34
const name = user.name;
const age = user.age;
```
`name` would have a value of the string `John Doe`, and `age` would have the number `34`.
Here's an equivalent assignment statement using the ES6 destructuring syntax:
```js
const { name, age } = user;
// name = 'John Doe', age = 34
```
Again, `name` would have a value of the string `John Doe`, and `age` would have the number `34`.
Here, the `name` and `age` variables will be created and assigned the values of their respective values from the `user` object. You can see how much cleaner this is.
You can extract as many or few values from the object as you want.

View File

@ -15,7 +15,7 @@ Consider the code below:
```js
const profileUpdate = (profileData) => {
const { name, age, nationality, location } = profileData;
// do something with these variables
}
```
@ -23,7 +23,7 @@ This effectively destructures the object sent into the function. This can also b
```js
const profileUpdate = ({ name, age, nationality, location }) => {
/* do something with these fields */
}
```

View File

@ -17,10 +17,12 @@ The result is similar to `Array.prototype.slice()`, as shown below:
```js
const [a, b, ...arr] = [1, 2, 3, 4, 5, 7];
console.log(a, b); // 1, 2
console.log(arr); // [3, 4, 5, 7]
console.log(a, b);
console.log(arr);
```
The console would display the values `1, 2` and `[3, 4, 5, 7]`.
Variables `a` and `b` take the first and second values from the array. After that, because of the rest parameter's presence, `arr` gets the rest of the values in the form of an array. The rest element only works correctly as the last variable in the list. As in, you cannot use the rest parameter to catch a subarray that leaves out the last element of the original array.
# --instructions--

View File

@ -31,16 +31,20 @@ class Book {
}
}
const novel = new Book('anonymous');
console.log(novel.writer); // anonymous
console.log(novel.writer);
novel.writer = 'newAuthor';
console.log(novel.writer); // newAuthor
console.log(novel.writer);
```
Notice the syntax used to invoke the getter and setter. They do not even look like functions. Getters and setters are important because they hide internal implementation details. **Note:** It is convention to precede the name of a private variable with an underscore (`_`). However, the practice itself does not make a variable private.
The console would display the strings `anonymous` and `newAuthor`.
Notice the syntax used to invoke the getter and setter. They do not even look like functions. Getters and setters are important because they hide internal implementation details.
**Note:** It is convention to precede the name of a private variable with an underscore (`_`). However, the practice itself does not make a variable private.
# --instructions--
Use the `class` keyword to create a Thermostat class. The constructor accepts a Fahrenheit temperature.
Use the `class` keyword to create a `Thermostat` class. The `constructor` accepts a Fahrenheit temperature.
In the class, create a `getter` to obtain the temperature in Celsius and a `setter` to set the temperature in Celsius.
@ -80,7 +84,7 @@ assert(
);
```
When instantiated with a Fahrenheit value, `Thermostat` should set the correct temperature.
When instantiated with a Fahrenheit value, `Thermostat` should set the correct `temperature`.
```js
assert(
@ -119,7 +123,7 @@ assert(
);
```
Calling the `setter` with a Celsius value should set the temperature.
Calling the `setter` with a Celsius value should set the `temperature`.
```js
assert(

View File

@ -16,10 +16,12 @@ Check out this code:
function howMany(...args) {
return "You have passed " + args.length + " arguments.";
}
console.log(howMany(0, 1, 2)); // You have passed 3 arguments.
console.log(howMany("string", null, [1, 2, 3], { })); // You have passed 4 arguments.
console.log(howMany(0, 1, 2));
console.log(howMany("string", null, [1, 2, 3], { }));
```
The console would display the strings `You have passed 3 arguments.` and `You have passed 4 arguments.`.
The rest parameter eliminates the need to check the `args` array and allows us to apply `map()`, `filter()` and `reduce()` on the parameters array.
# --instructions--

View File

@ -14,20 +14,24 @@ The ES5 code below uses `apply()` to compute the maximum value in an array:
```js
var arr = [6, 89, 3, 45];
var maximus = Math.max.apply(null, arr); // returns 89
var maximus = Math.max.apply(null, arr);
```
`maximus` would have a value of `89`.
We had to use `Math.max.apply(null, arr)` because `Math.max(arr)` returns `NaN`. `Math.max()` expects comma-separated arguments, but not an array. The spread operator makes this syntax much better to read and maintain.
```js
const arr = [6, 89, 3, 45];
const maximus = Math.max(...arr); // returns 89
const maximus = Math.max(...arr);
```
`maximus` would have a value of `89`.
`...arr` returns an unpacked array. In other words, it *spreads* the array. However, the spread operator only works in-place, like in an argument to a function or in an array literal. The following code will not work:
```js
const spreaded = ...arr; // will throw a syntax error
const spreaded = ...arr;
```
# --instructions--

View File

@ -11,26 +11,27 @@ dashedName: write-arrow-functions-with-parameters
Just like a regular function, you can pass arguments into an arrow function.
```js
// doubles input value and returns it
const doubler = (item) => item * 2;
doubler(4); // returns 8
doubler(4);
```
`doubler(4)` would return the value `8`.
If an arrow function has a single parameter, the parentheses enclosing the parameter may be omitted.
```js
// 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.
```js
// multiplies the first input value by the second and returns it
const multiplier = (item, multi) => item * multi;
multiplier(4, 2); // returns 8
multiplier(4, 2);
```
`multiplier(4, 2)` would return the value `8`.
# --instructions--
Rewrite the `myConcat` function which appends contents of `arr2` to `arr1` so that the function uses arrow function syntax.
@ -64,7 +65,7 @@ assert(
assert.deepEqual(myConcat([1, 2], [3, 4, 5]), [1, 2, 3, 4, 5]);
```
`function` keyword should not be used.
The `function` keyword should not be used.
```js
(getUserInput) => assert(!getUserInput('index').match(/function/g));

View File

@ -19,7 +19,7 @@ const person = {
};
```
With ES6, You can remove the `function` keyword and colon altogether when defining functions in objects. Here's an example of this syntax:
With ES6, you can remove the `function` keyword and colon altogether when defining functions in objects. Here's an example of this syntax:
```js
const person = {