From 338d7ee8a76ec6c1deeacc788f483713a302ab19 Mon Sep 17 00:00:00 2001 From: Deanna Tran Date: Wed, 8 May 2019 10:30:24 -0400 Subject: [PATCH] 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 --- curriculum/challenges/_meta/es6/meta.json | 4 ++-- ...parameter-to-reassign-array-elements.english.md} | 8 ++++---- ...t-parameter-with-function-parameters.english.md} | 8 ++++---- .../index.md | 13 ++++++------- .../index.md | 6 +++--- .../index.md | 2 +- guide/english/javascript/arrow-functions/index.md | 2 +- guide/english/javascript/rest-parameters/index.md | 4 ++-- .../function/function-length/index.md | 4 ++-- 9 files changed, 25 insertions(+), 26 deletions(-) rename curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/{use-destructuring-assignment-with-the-rest-operator-to-reassign-array-elements.english.md => use-destructuring-assignment-with-the-rest-parameter-to-reassign-array-elements.english.md} (76%) rename curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/{use-the-rest-operator-with-function-parameters.english.md => use-the-rest-parameter-with-function-parameters.english.md} (70%) rename guide/english/certifications/javascript-algorithms-and-data-structures/es6/{use-destructuring-assignment-with-the-rest-operator-to-reassign-array-elements => use-destructuring-assignment-with-the-rest-parameter-to-reassign-array-elements}/index.md (81%) rename guide/english/certifications/javascript-algorithms-and-data-structures/es6/{use-the-rest-operator-with-function-parameters => use-the-rest-parameter-with-function-parameters}/index.md (84%) diff --git a/curriculum/challenges/_meta/es6/meta.json b/curriculum/challenges/_meta/es6/meta.json index bae929376b..62758afbb7 100644 --- a/curriculum/challenges/_meta/es6/meta.json +++ b/curriculum/challenges/_meta/es6/meta.json @@ -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", diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-with-the-rest-operator-to-reassign-array-elements.english.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-with-the-rest-parameter-to-reassign-array-elements.english.md similarity index 76% rename from curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-with-the-rest-operator-to-reassign-array-elements.english.md rename to curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-with-the-rest-parameter-to-reassign-array-elements.english.md index 09ea6b60e7..e05f213689 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-with-the-rest-operator-to-reassign-array-elements.english.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-with-the-rest-parameter-to-reassign-array-elements.english.md @@ -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 Array.prototype.slice(), as shown below:
const [a, b, ...arr] = [1, 2, 3, 4, 5, 7];
console.log(a, b); // 1, 2
console.log(arr); // [3, 4, 5, 7]
-Variables a and b take the first and second values from the array. After that, because of rest operator's presence, arr 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 a and b take the first and second values from the array. After that, because of rest parameter's presence, arr 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. ## Instructions
-Use destructuring assignment with the rest operator to perform an effective Array.prototype.slice() so that arr is a sub-array of the original array source with the first two elements omitted. +Use destructuring assignment with the rest parameter to perform an effective Array.prototype.slice() so that arr is a sub-array of the original array source with the first two elements omitted.
## Tests diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-the-rest-operator-with-function-parameters.english.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-the-rest-parameter-with-function-parameters.english.md similarity index 70% rename from curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-the-rest-operator-with-function-parameters.english.md rename to curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-the-rest-parameter-with-function-parameters.english.md index c73748fa2c..4de3dac6af 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-the-rest-operator-with-function-parameters.english.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-the-rest-parameter-with-function-parameters.english.md @@ -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
-In order to help us create more flexible functions, ES6 introduces the rest operator 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 rest parameter 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: -
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.
-The rest operator eliminates the need to check the args array and allows us to apply map(), filter() and reduce() on the parameters array. +
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.
+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 diff --git a/guide/english/certifications/javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-with-the-rest-operator-to-reassign-array-elements/index.md b/guide/english/certifications/javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-with-the-rest-parameter-to-reassign-array-elements/index.md similarity index 81% rename from guide/english/certifications/javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-with-the-rest-operator-to-reassign-array-elements/index.md rename to guide/english/certifications/javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-with-the-rest-parameter-to-reassign-array-elements/index.md index 4d04428c44..a0631401a4 100644 --- a/guide/english/certifications/javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-with-the-rest-operator-to-reassign-array-elements/index.md +++ b/guide/english/certifications/javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-with-the-rest-parameter-to-reassign-array-elements/index.md @@ -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; } diff --git a/guide/english/certifications/javascript-algorithms-and-data-structures/es6/use-the-rest-operator-with-function-parameters/index.md b/guide/english/certifications/javascript-algorithms-and-data-structures/es6/use-the-rest-parameter-with-function-parameters/index.md similarity index 84% rename from guide/english/certifications/javascript-algorithms-and-data-structures/es6/use-the-rest-operator-with-function-parameters/index.md rename to guide/english/certifications/javascript-algorithms-and-data-structures/es6/use-the-rest-parameter-with-function-parameters/index.md index 77e0eea951..004fa47f69 100644 --- a/guide/english/certifications/javascript-algorithms-and-data-structures/es6/use-the-rest-operator-with-function-parameters/index.md +++ b/guide/english/certifications/javascript-algorithms-and-data-structures/es6/use-the-rest-parameter-with-function-parameters/index.md @@ -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 +alt="Image of youtube video link spread and rest parameter " width="240" height="180" border="10" /> ### Example This code diff --git a/guide/english/certifications/javascript-algorithms-and-data-structures/es6/use-the-spread-operator-to-evaluate-arrays-in-place/index.md b/guide/english/certifications/javascript-algorithms-and-data-structures/es6/use-the-spread-operator-to-evaluate-arrays-in-place/index.md index f65b77276f..e904dd0bf7 100644 --- a/guide/english/certifications/javascript-algorithms-and-data-structures/es6/use-the-spread-operator-to-evaluate-arrays-in-place/index.md +++ b/guide/english/certifications/javascript-algorithms-and-data-structures/es6/use-the-spread-operator-to-evaluate-arrays-in-place/index.md @@ -12,7 +12,7 @@ title: Use the Spread Operator to Evaluate Arrays In-Place ### Video Explaining Spread Operator and Rest Parameter +alt="Image of youtube video link spread and rest parameter " width="240" height="180" border="10" /> ### 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") diff --git a/guide/english/javascript/arrow-functions/index.md b/guide/english/javascript/arrow-functions/index.md index eacd99dd77..e8e05a6185 100644 --- a/guide/english/javascript/arrow-functions/index.md +++ b/guide/english/javascript/arrow-functions/index.md @@ -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]); diff --git a/guide/english/javascript/rest-parameters/index.md b/guide/english/javascript/rest-parameters/index.md index 27f547ca3b..a1e876001e 100644 --- a/guide/english/javascript/rest-parameters/index.md +++ b/guide/english/javascript/rest-parameters/index.md @@ -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) { diff --git a/guide/english/javascript/standard-objects/function/function-length/index.md b/guide/english/javascript/standard-objects/function/function-length/index.md index e024f16e7a..0533ee098a 100644 --- a/guide/english/javascript/standard-objects/function/function-length/index.md +++ b/guide/english/javascript/standard-objects/function/function-length/index.md @@ -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) { }