From 9252f965661ddcb3ef6b78903286f30e658cf473 Mon Sep 17 00:00:00 2001 From: Randell Dawson <5313213+RandellDawson@users.noreply.github.com> Date: Sun, 8 Mar 2020 07:46:28 -0700 Subject: [PATCH] fix(curriculum): Consolidated comments for JavaScript Algorithms and Data Structures challenges - part 4 of 4 (#38267) * fix: consolidate comments Co-authored-by: Parth Parth <34807532+thecodingaviator@users.noreply.github.com> --- .../build-javascript-objects.english.md | 10 ---------- .../testing-objects-for-properties.english.md | 4 ++-- ...sole-to-check-the-value-of-a-variable.english.md | 2 +- ...ypeof-to-check-the-type-of-a-variable.english.md | 2 +- .../mutate-an-array-declared-with-const.english.md | 2 +- ...default-parameters-for-your-functions.english.md | 5 ++--- ...nment-to-assign-variables-from-arrays.english.md | 3 --- ...-assign-variables-from-nested-objects.english.md | 10 +++------- ...ment-to-assign-variables-from-objects.english.md | 9 ++------- ...gnment-to-extract-values-from-objects.english.md | 10 ++-------- ...s-an-object-as-a-functions-parameters.english.md | 3 --- ...-parameter-to-reassign-array-elements.english.md | 13 ++++++------- ...etters-to-control-access-to-an-object.english.md | 12 ++++++------ ...tions-using-object-property-shorthand.english.md | 1 - ...an-array-using-concat-instead-of-push.english.md | 4 ++-- ...mming-to-convert-strings-to-url-slugs.english.md | 13 +++++-------- ...-effects-using-functional-programming.english.md | 6 +++--- ...y-into-a-string-using-the-join-method.english.md | 8 ++++---- ...ne-two-arrays-using-the-concat-method.english.md | 8 ++++---- .../implement-map-on-a-prototype.english.md | 10 +++++----- ...ment-the-filter-method-on-a-prototype.english.md | 11 +++++------ ...n-to-currying-and-partial-application.english.md | 4 ++-- .../learn-about-functional-programming.english.md | 2 -- ...oid-external-dependence-in-a-function.english.md | 8 ++++---- ...tor-global-variables-out-of-functions.english.md | 2 +- ...n-array-using-slice-instead-of-splice.english.md | 8 ++++---- ...y-without-changing-the-original-array.english.md | 8 ++++---- ...rt-of-an-array-using-the-slice-method.english.md | 8 ++++---- ...-alphabetically-using-the-sort-method.english.md | 8 ++++---- ...-into-an-array-using-the-split-method.english.md | 8 ++++---- ...-element-in-an-array-meets-a-criteria.english.md | 8 ++++---- ...-method-to-extract-data-from-an-array.english.md | 12 ++++++------ ...-method-to-extract-data-from-an-array.english.md | 8 ++++---- ...use-the-reduce-method-to-analyze-data.english.md | 8 ++++---- ...-elements-in-an-array-meet-a-criteria.english.md | 8 ++++---- .../add-methods-after-inheritance.english.md | 7 ++----- .../change-the-prototype-to-a-new-object.english.md | 2 +- .../inherit-behaviors-from-a-supertype.english.md | 5 +---- .../iterate-over-all-properties.english.md | 2 +- .../override-inherited-methods.english.md | 4 ++-- ...set-an-inherited-constructor-property.english.md | 2 +- ...rototype-to-an-instance-of-the-parent.english.md | 4 ++-- .../understand-own-properties.english.md | 2 +- .../understand-the-constructor-property.english.md | 2 +- ...where-an-objects-prototype-comes-from.english.md | 2 +- .../use-a-constructor-to-create-objects.english.md | 2 +- ...on-behavior-between-unrelated-objects.english.md | 2 +- ...to-access-the-properties-of-an-object.english.md | 2 +- ...e-properties-to-reduce-duplicate-code.english.md | 2 +- ...n-objects-constructor-with-instanceof.english.md | 2 +- .../find-one-or-more-criminals-in-a-hunt.english.md | 11 ----------- 51 files changed, 121 insertions(+), 178 deletions(-) diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/build-javascript-objects.english.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/build-javascript-objects.english.md index c5b2a35216..f88ff6a465 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/build-javascript-objects.english.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/build-javascript-objects.english.md @@ -67,16 +67,6 @@ tests:
highToday
variable.
testString: assert(code.match(/(var|const|let)\s*{\s*today\s*:\s*{\s*(high\s*:\s*highToday[^}]*|[^,]*,\s*high\s*:\s*highToday\s*)}\s*}\s*=\s*LOCAL_FORECAST(;|\s+|\/\/)/g));
+ - text: lowToday
should be equal to 64
and highToday
should be equal to 77
.
+ testString: assert(lowToday === 64 && highToday === 77);
```
@@ -71,9 +73,6 @@ const lowToday = LOCAL_FORECAST.today.low;
const highToday = LOCAL_FORECAST.today.high;
// Only change code above this line
-
-console.log(lowToday); // should be 64
-console.log(highToday); // should be 77
```
@@ -88,11 +87,8 @@ const LOCAL_FORECAST = {
today: { low: 64, high: 77 },
tomorrow: { low: 68, high: 80 }
};
-
+
const { today: { low: lowToday, high: highToday }} = LOCAL_FORECAST;
-
-console.log(highToday); // should be 77
-console.log(highTomorrow); // should be 80
```
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-objects.english.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-objects.english.md
index bd3123aab1..2f209530dd 100644
--- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-objects.english.md
+++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-objects.english.md
@@ -41,6 +41,8 @@ tests:
testString: assert(code.match(/(var|const|let)\s*{\s*(today\s*:\s*highToday[^}]*|[^,]*,\s*today\s*:\s*highToday\s*)}\s*=\s*HIGH_TEMPERATURES(;|\s+|\/\/)/g));
- text: You should use destructuring to create the highTomorrow
variable.
testString: assert(code.match(/(var|const|let)\s*{\s*(tomorrow\s*:\s*highTomorrow[^}]*|[^,]*,\s*tomorrow\s*:\s*highTomorrow\s*)}\s*=\s*HIGH_TEMPERATURES(;|\s+|\/\/)/g));
+ - text: highToday
should be equal to 77
and highTomorrow
should be equal to 80
.
+ testString: assert(highToday === 77 && highTomorrow === 80);
```
@@ -62,10 +64,6 @@ const highToday = HIGH_TEMPERATURES.today;
const highTomorrow = HIGH_TEMPERATURES.tomorrow;
// Only change code above this line
-
-console.log(yesterday) // should be not defined
-console.log(highToday); // should be 77
-console.log(highTomorrow); // should be 80
```
@@ -82,9 +80,6 @@ const HIGH_TEMPERATURES = {
};
const { today: highToday, tomorrow: highTomorrow } = HIGH_TEMPERATURES;
-
-console.log(highToday); // should be 77
-console.log(highTomorrow); // should be 80
```
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-extract-values-from-objects.english.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-extract-values-from-objects.english.md
index c0e29f673b..d04a619427 100644
--- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-extract-values-from-objects.english.md
+++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-extract-values-from-objects.english.md
@@ -46,6 +46,8 @@ tests:
testString: assert(code.match(/(var|let|const)\s*{\s*(today[^}]*|[^,]*,\s*today)\s*}\s*=\s*HIGH_TEMPERATURES(;|\s+|\/\/)/g));
- text: You should use destructuring to create the tomorrow
variable.
testString: assert(code.match(/(var|let|const)\s*{\s*(tomorrow[^}]*|[^,]*,\s*tomorrow)\s*}\s*=\s*HIGH_TEMPERATURES(;|\s+|\/\/)/g));
+ - text: today
should be equal to 77
and tomorrow
should be equal to 80
.
+ testString: assert(today === 77 && tomorrow === 80);
```
@@ -67,10 +69,6 @@ const today = HIGH_TEMPERATURES.today;
const tomorrow = HIGH_TEMPERATURES.tomorrow;
// Only change code above this line
-
-console.log(yesterday) // should be not defined
-console.log(today); // should be 77
-console.log(tomorrow); // should be 80
```
@@ -87,10 +85,6 @@ const HIGH_TEMPERATURES = {
};
const { today, tomorrow } = HIGH_TEMPERATURES;
-
-console.log(yesterday) // should be not defined
-console.log(today); // should be 77
-console.log(tomorrow); // should be 80
```
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-pass-an-object-as-a-functions-parameters.english.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-pass-an-object-as-a-functions-parameters.english.md
index 380376ba23..290ed50c49 100644
--- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-pass-an-object-as-a-functions-parameters.english.md
+++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-pass-an-object-as-a-functions-parameters.english.md
@@ -67,13 +67,10 @@ const stats = {
average: 35.85
};
-// Use function argument destructuring
// Only change code below this line
const half = (stats) => (stats.max + stats.min) / 2.0;
// Only change code above this line
-console.log(stats); // should be object
-console.log(half(stats)); // should be 28.015
```
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-with-the-rest-parameter-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
index a34f81028c..68e6b3335a 100644
--- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-with-the-rest-parameter-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
@@ -32,6 +32,8 @@ Use destructuring assignment with the rest parameter to perform an effective [3,4,5,6,7,8,9,10]
testString: assert(arr.every((v, i) => v === i + 3) && arr.length === 8);
+ - text: source
should be [1,2,3,4,5,6,7,8,9,10]
+ testString: assert(source.every((v, i) => v === i + 1) && source.length === 10);
- text: Array.slice()
should not be used.
testString: getUserInput => assert(!getUserInput('index').match(/slice/g));
- text: Destructuring on list
should be used.
@@ -50,14 +52,13 @@ tests:
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
- // change code above this line
+ // Only change code below this line
+ const arr = list; // Change this line
+ // Only change code above this line
return arr;
}
const arr = removeFirstTwo(source);
-console.log(arr); // should be [3,4,5,6,7,8,9,10]
-console.log(source); // should be [1,2,3,4,5,6,7,8,9,10];
+
```
@@ -73,9 +74,7 @@ console.log(source); // should be [1,2,3,4,5,6,7,8,9,10];
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 code above this line
return arr;
}
const arr = removeFirstTwo(source);
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-getters-and-setters-to-control-access-to-an-object.english.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-getters-and-setters-to-control-access-to-an-object.english.md
index fec340f2d4..eed16750eb 100644
--- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-getters-and-setters-to-control-access-to-an-object.english.md
+++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-getters-and-setters-to-control-access-to-an-object.english.md
@@ -79,10 +79,10 @@ tests:
// Only change code above this line
-const thermos = new Thermostat(76); // setting in Fahrenheit scale
-let temp = thermos.temperature; // 24.44 in C
+const thermos = new Thermostat(76); // Setting in Fahrenheit scale
+let temp = thermos.temperature; // 24.44 in Celsius
thermos.temperature = 26;
-temp = thermos.temperature; // 26 in C
+temp = thermos.temperature; // 26 in Celsius
```
@@ -107,10 +107,10 @@ class Thermostat {
}
}
-const thermos = new Thermostat(76); // setting in Fahrenheit scale
-let temp = thermos.temperature; // 24.44 in C
+const thermos = new Thermostat(76); // Setting in Fahrenheit scale
+let temp = thermos.temperature; // 24.44 in Celsius
thermos.temperature = 26;
-temp = thermos.temperature; // 26 in C
+temp = thermos.temperature; // 26 in Celsius
```
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/write-concise-object-literal-declarations-using-object-property-shorthand.english.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/write-concise-object-literal-declarations-using-object-property-shorthand.english.md
index 0c369e1ab7..9234dbbcaf 100644
--- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/write-concise-object-literal-declarations-using-object-property-shorthand.english.md
+++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/write-concise-object-literal-declarations-using-object-property-shorthand.english.md
@@ -62,7 +62,6 @@ const createPerson = (name, age, gender) => {
};
// Only change code above this line
};
-console.log(createPerson("Zodiac Hasbro", 56, "male")); // returns a proper object
```
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/add-elements-to-the-end-of-an-array-using-concat-instead-of-push.english.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/add-elements-to-the-end-of-an-array-using-concat-instead-of-push.english.md
index b33690e191..43485eae8b 100644
--- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/add-elements-to-the-end-of-an-array-using-concat-instead-of-push.english.md
+++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/add-elements-to-the-end-of-an-array-using-concat-instead-of-push.english.md
@@ -52,10 +52,10 @@ tests:
```js
function nonMutatingPush(original, newItem) {
- // Add your code below this line
+ // Only change code below this line
return original.push(newItem);
- // Add your code above this line
+ // Only change code above this line
}
var first = [1, 2, 3];
var second = [4, 5];
diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/apply-functional-programming-to-convert-strings-to-url-slugs.english.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/apply-functional-programming-to-convert-strings-to-url-slugs.english.md
index 33a8aacc36..5f3699fb79 100644
--- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/apply-functional-programming-to-convert-strings-to-url-slugs.english.md
+++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/apply-functional-programming-to-convert-strings-to-url-slugs.english.md
@@ -49,15 +49,15 @@ tests: