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>
This commit is contained in:
Randell Dawson
2020-03-08 07:46:28 -07:00
committed by GitHub
parent dbf3815fc7
commit 9252f96566
51 changed files with 121 additions and 178 deletions

View File

@@ -56,7 +56,7 @@ function editInPlace() {
'use strict';
// Only change code below this line
// s = [2, 5, 7]; <- this is invalid
// Using s = [2, 5, 7] would be invalid
// Only change code above this line
}

View File

@@ -47,10 +47,9 @@ tests:
<div id='js-seed'>
```js
// Only change code below this line
const increment = (number, value) => number + value;
console.log(increment(5, 2)); // returns 7
console.log(increment(5)); // returns 6
// Only change code above this line
```
</div>

View File

@@ -56,9 +56,6 @@ tests:
let a = 8, b = 6;
// Only change code below this line
// Only change code above this line
console.log(a); // should be 6
console.log(b); // should be 8
```
</div>

View File

@@ -50,6 +50,8 @@ tests:
testString: assert(code.match(/(var|const|let)\s*{\s*today\s*:\s*{\s*(low\s*:\s*lowToday[^}]*|[^,]*,\s*low\s*:\s*lowToday\s*)}\s*}\s*=\s*LOCAL_FORECAST(;|\s+|\/\/)/g));
- text: You should use destructuring to create the <code>highToday</code> 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: <code>lowToday</code> should be equal to <code>64</code> and <code>highToday</code> should be equal to <code>77</code>.
testString: assert(lowToday === 64 && highToday === 77);
```
</section>
@@ -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
```
</div>
@@ -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
```
</section>

View File

@@ -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 <code>highTomorrow</code> 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: <code>highToday</code> should be equal to <code>77</code> and <code>highTomorrow</code> should be equal to <code>80</code>.
testString: assert(highToday === 77 && highTomorrow === 80);
```
</section>
@@ -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
```
</div>
@@ -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
```
</section>

View File

@@ -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 <code>tomorrow</code> variable.
testString: assert(code.match(/(var|let|const)\s*{\s*(tomorrow[^}]*|[^,]*,\s*tomorrow)\s*}\s*=\s*HIGH_TEMPERATURES(;|\s+|\/\/)/g));
- text: <code>today</code> should be equal to <code>77</code> and <code>tomorrow</code> should be equal to <code>80</code>.
testString: assert(today === 77 && tomorrow === 80);
```
</section>
@@ -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
```
</div>
@@ -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
```
</section>

View File

@@ -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
```
</div>

View File

@@ -32,6 +32,8 @@ Use destructuring assignment with the rest parameter to perform an effective <co
tests:
- text: <code>arr</code> should be <code>[3,4,5,6,7,8,9,10]</code>
testString: assert(arr.every((v, i) => v === i + 3) && arr.length === 8);
- text: <code>source</code> should be <code>[1,2,3,4,5,6,7,8,9,10]</code>
testString: assert(source.every((v, i) => v === i + 1) && source.length === 10);
- text: <code>Array.slice()</code> should not be used.
testString: getUserInput => assert(!getUserInput('index').match(/slice/g));
- text: Destructuring on <code>list</code> 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];
```
</div>
@@ -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);

View File

@@ -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
```
</div>
@@ -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
```
</section>

View File

@@ -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
```
</div>