Change "rest operator" to say "rest parameter" in challenges and guide (#35496)

* change es6 challenges rest operator to param

* fix rest parameter typos

* change rest operator to parameter in guide

* fix casing

* change rest operator to rest parameter in guide

* change rest operator to rest parameter in curriculum

* remove extra whitespace

* remove whitespaces

* remove whitespace

* fix: removed arabic file

* fix: removed chinese file
This commit is contained in:
Deanna Tran
2019-05-08 10:30:24 -04:00
committed by Jaka Kranjc
parent 4f73b5a7f3
commit 338d7ee8a7
9 changed files with 25 additions and 26 deletions

View File

@ -46,7 +46,7 @@
],
[
"587d7b88367417b2b2512b47",
"Use the Rest Operator with Function Parameters"
"Use the Rest Parameter with Function Parameters"
],
[
"587d7b89367417b2b2512b48",
@ -66,7 +66,7 @@
],
[
"587d7b8a367417b2b2512b4c",
"Use Destructuring Assignment with the Rest Operator to Reassign Array Elements"
"Use Destructuring Assignment with the Rest Parameter to Reassign Array Elements"
],
[
"587d7b8a367417b2b2512b4d",

View File

@ -1,6 +1,6 @@
---
id: 587d7b8a367417b2b2512b4c
title: Use Destructuring Assignment with the Rest Operator to Reassign Array Elements
title: Use Destructuring Assignment with the Rest Parameter to Reassign Array Elements
challengeType: 1
---
@ -9,13 +9,13 @@ challengeType: 1
In some situations involving array destructuring, we might want to collect the rest of the elements into a separate array.
The result is similar to <code>Array.prototype.slice()</code>, as shown below:
<blockquote>const [a, b, ...arr] = [1, 2, 3, 4, 5, 7];<br>console.log(a, b); // 1, 2<br>console.log(arr); // [3, 4, 5, 7]</blockquote>
Variables <code>a</code> and <code>b</code> take the first and second values from the array. After that, because of rest operator's presence, <code>arr</code> gets 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 operator to catch a subarray that leaves out last element of the original array.
Variables <code>a</code> and <code>b</code> take the first and second values from the array. After that, because of rest parameter's presence, <code>arr</code> gets 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 last element of the original array.
</section>
## Instructions
<section id='instructions'>
Use destructuring assignment with the rest operator to perform an effective <code>Array.prototype.slice()</code> so that <code>arr</code> is a sub-array of the original array <code>source</code> with the first two elements omitted.
Use destructuring assignment with the rest parameter to perform an effective <code>Array.prototype.slice()</code> so that <code>arr</code> is a sub-array of the original array <code>source</code> with the first two elements omitted.
</section>
## Tests

View File

@ -1,15 +1,15 @@
---
id: 587d7b88367417b2b2512b47
title: Use the Rest Operator with Function Parameters
title: Use the Rest Parameter with Function Parameters
challengeType: 1
---
## Description
<section id='description'>
In order to help us create more flexible functions, ES6 introduces the <dfn>rest operator</dfn> for function parameters. With the rest operator, you can create functions that take a variable number of arguments. These arguments are stored in an array that can be accessed later from inside the function.
In order to help us create more flexible functions, ES6 introduces the <dfn>rest parameter</dfn> for function parameters. With the rest parameter, you can create functions that take a variable number of arguments. These arguments are stored in an array that can be accessed later from inside the function.
Check out this code:
<blockquote>function howMany(...args) {<br>&nbsp;&nbsp;return "You have passed " + args.length + " arguments.";<br>}<br>console.log(howMany(0, 1, 2)); // You have passed 3 arguments.<br>console.log(howMany("string", null, [1, 2, 3], { })); // You have passed 4 arguments.</blockquote>
The rest operator eliminates the need to check the <code>args</code> array and allows us to apply <code>map()</code>, <code>filter()</code> and <code>reduce()</code> on the parameters array.
<blockquote>function howMany(...args) {<br>&nbsp;&nbsp;return "You have passed " + args.length + " arguments.";<br>}<br>console.log(howMany(0, 1, 2)); // You have passed 3 arguments<br>console.log(howMany("string", null, [1, 2, 3], { })); // You have passed 4 arguments.</blockquote>
The rest parameter eliminates the need to check the <code>args</code> array and allows us to apply <code>map()</code>, <code>filter()</code> and <code>reduce()</code> on the parameters array.
</section>
## Instructions

View File

@ -1,11 +1,10 @@
---
title: Use Destructuring Assignment with the Rest Operator to Reassign Array Elements
title: Use Destructuring Assignment with the Rest Parameter to Reassign Array Elements
---
## Use Destructuring Assignment with the Rest Operator to Reassign Array Elements
## Use Destructuring Assignment with the Rest Parameter to Reassign Array Elements
Remember that the rest parameter allows for variable numbers of arguments. In this challenge, you have to get rid of the first two elements of an array.
Remember that the rest operator allows for variable numbers of arguments. In this challenge, you have to get rid of the first two elements of an array.
## Hint 1:
## Hint 1:
Assign the first two elements to two random variables.
@ -39,8 +38,8 @@ function removeFirstTwo(list) {
// change code above this line
return arr;
}
```
```
## Spoiler Alert - Solution Ahead!
You can use random variables to omit the first two values:
@ -67,7 +66,7 @@ const source = [1,2,3,4,5,6,7,8,9,10];
function removeFirstTwo(list) {
"use strict";
// change code below this line
const [,,...arr] = list; // change this
const [a, b, ...arr] = list;
// change code above this line
return arr;
}

View File

@ -1,7 +1,7 @@
---
title: Use the Rest Operator with Function Parameters
title: Use the Rest Parameter with Function Parameters
---
## Use the Rest Operator with Function Parameters
## Use the Rest Parameter with Function Parameters
### Rest parameter explanation
[Mozilla Developer Network](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters "Mozilla Developer Network")
@ -13,7 +13,7 @@ title: Use the Rest Operator with Function Parameters
<a href="http://www.youtube.com/watch?feature=player_embedded&v=iLx4ma8ZqvQ
" target="_blank"><img src="http://img.youtube.com/vi/iLx4ma8ZqvQ/0.jpg"
alt="Image of youtube video link spread and rest operator " width="240" height="180" border="10" /></a>
alt="Image of youtube video link spread and rest parameter " width="240" height="180" border="10" /></a>
### Example
This code

View File

@ -12,7 +12,7 @@ title: Use the Spread Operator to Evaluate Arrays In-Place
### Video Explaining Spread Operator and Rest Parameter
<a href="http://www.youtube.com/watch?feature=player_embedded&v=iLx4ma8ZqvQ
" target="_blank"><img src="http://img.youtube.com/vi/iLx4ma8ZqvQ/0.jpg"
alt="Image of youtube video link spread and rest operator " width="240" height="180" border="10" /></a>
alt="Image of youtube video link spread and rest parameter " width="240" height="180" border="10" /></a>
### Information About apply() Method
[Mozilla Developer Network Apply Method](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply "Mozilla Developer Network")

View File

@ -80,7 +80,7 @@ function Person(){
var p = new Person();
```
An arrow function does not have its own `arguments` object. For example, if you do not know the number of arguments passed to a function, instead of using `arguments` you can use the `rest` operator:
An arrow function does not have its own `arguments` object. For example, if you do not know the number of arguments passed to a function, instead of using `arguments` you can use the `rest` parameter:
```javascript
const myFunc = (...n) => {
console.log('The first argument is', n[0]);

View File

@ -3,7 +3,7 @@ title: Rest Parameters
---
## Rest Parameters
In ES6, the rest paramter syntax `...` allows you to gather up an indefinite number of arguments into an array.
In ES6, the rest parameter syntax `...` allows you to gather up an indefinite number of arguments into an array.
Even though they look the same, it does the opposite of the spread operator, which takes every item from an iterable and spreads them out into their individual values.
@ -18,7 +18,7 @@ myFunc( 1, 2, 3, 4, 5); // [1,2,3,4,5]
```
You can prefix a function's last parameter with `...` when you want to do something with the initial paramters and then treat all of the remaining parameters differently.
You can prefix a function's last parameter with `...` when you want to do something with the initial parameters and then treat all of the remaining parameters differently.
```js
function convertCurrency(rate, fee, ...amounts) {

View File

@ -18,9 +18,9 @@ console.log(oneArg.length); // 1
### ES2015 Syntax
ES2015, or ES6 as it is commonly called, introduced the rest operator and default function parameters. Both of these additions change the way the `length` property works.
ES2015, or ES6 as it is commonly called, introduced the rest parameter and default function parameters. Both of these additions change the way the `length` property works.
If either the rest operator or default parameters are used in a function declaration the `length` property will only include the number of arguments before a rest operator or a default parameter.
If either the rest parameter or default parameters are used in a function declaration the `length` property will only include the number of arguments before a rest parameter or a default parameter.
```javascript
function withRest(...args) { }