fix(curriculum): Consolidated comments for JavaScript Algorithms and Data Structures challenges - part 1 of 4 (#38258)
* fix: consolidate/remove comments * fix: remove => from comment * fix: reverted changes to add same changes to another PR * fix: removed 'the' from sentence Co-Authored-By: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> * fix: removed 'the' from the sentence Co-Authored-By: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
This commit is contained in:
@ -43,9 +43,9 @@ tests:
|
||||
```html
|
||||
<html>
|
||||
<body>
|
||||
<!-- add your code below -->
|
||||
<!-- Only change code below this line -->
|
||||
|
||||
<!-- add your code above -->
|
||||
<!-- Only change code above this line -->
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
@ -59,9 +59,7 @@ tests:
|
||||
```html
|
||||
<html>
|
||||
<body>
|
||||
<!-- add your code below -->
|
||||
<script type="module" src="index.js"></script>
|
||||
<!-- add your code above -->
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
@ -37,7 +37,16 @@ This new way of creating strings gives you more flexibility to create robust str
|
||||
## Instructions
|
||||
<section id='instructions'>
|
||||
Use template literal syntax with backticks to display each entry of the <code>result</code> object's <code>failure</code> array. Each entry should be wrapped inside an <code>li</code> element with the class attribute <code>text-warning</code>, and listed within the <code>resultDisplayArray</code>.
|
||||
Use an iterator method (any kind of loop) to get the desired output.
|
||||
Use an iterator method (any kind of loop) to get the desired output (shown below).
|
||||
|
||||
```js
|
||||
[
|
||||
'<li class="text-warning">no-var</li>',
|
||||
'<li class="text-warning">var-on-top</li>',
|
||||
'<li class="text-warning">linebreak</li>'
|
||||
]
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Tests
|
||||
@ -71,18 +80,13 @@ const result = {
|
||||
function makeList(arr) {
|
||||
"use strict";
|
||||
|
||||
// change code below this line
|
||||
// Only change code below this line
|
||||
const resultDisplayArray = null;
|
||||
// change code above this line
|
||||
// Only change code above this line
|
||||
|
||||
return resultDisplayArray;
|
||||
}
|
||||
/**
|
||||
* makeList(result.failure) should return:
|
||||
* [ `<li class="text-warning">no-var</li>`,
|
||||
* `<li class="text-warning">var-on-top</li>`,
|
||||
* `<li class="text-warning">linebreak</li>` ]
|
||||
**/
|
||||
|
||||
const resultDisplayArray = makeList(result.failure);
|
||||
```
|
||||
|
||||
@ -108,12 +112,7 @@ function makeList(arr) {
|
||||
|
||||
return resultDisplayArray;
|
||||
}
|
||||
/**
|
||||
* makeList(result.failure) should return:
|
||||
* [ `<li class="text-warning">no-var</li>`,
|
||||
* `<li class="text-warning">var-on-top</li>`,
|
||||
* `<li class="text-warning">linebreak</li>` ]
|
||||
**/
|
||||
|
||||
const resultDisplayArray = makeList(result.failure);
|
||||
```
|
||||
|
||||
|
@ -53,14 +53,14 @@ tests:
|
||||
function printManyTimes(str) {
|
||||
"use strict";
|
||||
|
||||
// change code below this line
|
||||
// Only change code below this line
|
||||
|
||||
var sentence = str + " is cool!";
|
||||
for (var i = 0; i < str.length; i+=2) {
|
||||
console.log(sentence);
|
||||
}
|
||||
|
||||
// change code above this line
|
||||
// Only change code above this line
|
||||
|
||||
}
|
||||
printManyTimes("freeCodeCamp");
|
||||
@ -79,15 +79,11 @@ printManyTimes("freeCodeCamp");
|
||||
function printManyTimes(str) {
|
||||
"use strict";
|
||||
|
||||
// change code below this line
|
||||
|
||||
const SENTENCE = str + " is cool!";
|
||||
for (let i = 0; i < str.length; i+=2) {
|
||||
console.log(SENTENCE);
|
||||
}
|
||||
|
||||
// change code above this line
|
||||
|
||||
}
|
||||
printManyTimes("freeCodeCamp");
|
||||
```
|
||||
|
@ -54,11 +54,11 @@ tests:
|
||||
const s = [5, 7, 2];
|
||||
function editInPlace() {
|
||||
'use strict';
|
||||
// change code below this line
|
||||
// Only change code below this line
|
||||
|
||||
// s = [2, 5, 7]; <- this is invalid
|
||||
|
||||
// change code above this line
|
||||
// Only change code above this line
|
||||
}
|
||||
editInPlace();
|
||||
```
|
||||
@ -76,13 +76,9 @@ editInPlace();
|
||||
const s = [5, 7, 2];
|
||||
function editInPlace() {
|
||||
'use strict';
|
||||
// change code below this line
|
||||
|
||||
// s = [2, 5, 7]; <- this is invalid
|
||||
s[0] = 2;
|
||||
s[1] = 5;
|
||||
s[2] = 7;
|
||||
// change code above this line
|
||||
}
|
||||
editInPlace();
|
||||
```
|
||||
|
@ -58,10 +58,10 @@ function freezeObj() {
|
||||
const MATH_CONSTANTS = {
|
||||
PI: 3.14
|
||||
};
|
||||
// change code below this line
|
||||
// Only change code below this line
|
||||
|
||||
|
||||
// change code above this line
|
||||
// Only change code above this line
|
||||
try {
|
||||
MATH_CONSTANTS.PI = 99;
|
||||
} catch(ex) {
|
||||
@ -87,10 +87,8 @@ function freezeObj() {
|
||||
const MATH_CONSTANTS = {
|
||||
PI: 3.14
|
||||
};
|
||||
// change code below this line
|
||||
Object.freeze(MATH_CONSTANTS);
|
||||
|
||||
// change code above this line
|
||||
try {
|
||||
MATH_CONSTANTS.PI = 99;
|
||||
} catch(ex) {
|
||||
|
@ -65,12 +65,12 @@ tests:
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
/* Alter code below this line */
|
||||
// Only change code below this line
|
||||
|
||||
/* Alter code above this line */
|
||||
// Only change code above this line
|
||||
|
||||
const carrot = new Vegetable('carrot');
|
||||
console.log(carrot.name); // => should be 'carrot'
|
||||
console.log(carrot.name); // Should display 'carrot'
|
||||
```
|
||||
|
||||
</div>
|
||||
|
@ -54,9 +54,9 @@ tests:
|
||||
|
||||
```js
|
||||
let a = 8, b = 6;
|
||||
// change code below this line
|
||||
// Only change code below this line
|
||||
|
||||
// change code above this line
|
||||
// Only change code above this line
|
||||
console.log(a); // should be 6
|
||||
console.log(b); // should be 8
|
||||
```
|
||||
|
@ -65,12 +65,12 @@ const LOCAL_FORECAST = {
|
||||
tomorrow: { low: 68, high: 80 }
|
||||
};
|
||||
|
||||
// change code below this line
|
||||
// Only change code below this line
|
||||
|
||||
const lowToday = LOCAL_FORECAST.today.low;
|
||||
const highToday = LOCAL_FORECAST.today.high;
|
||||
|
||||
// change code above this line
|
||||
// Only change code above this line
|
||||
|
||||
console.log(lowToday); // should be 64
|
||||
console.log(highToday); // should be 77
|
||||
@ -89,12 +89,8 @@ const LOCAL_FORECAST = {
|
||||
tomorrow: { low: 68, high: 80 }
|
||||
};
|
||||
|
||||
// change code below this line
|
||||
|
||||
const { today: { low: lowToday, high: highToday }} = LOCAL_FORECAST;
|
||||
|
||||
// change code above this line
|
||||
|
||||
console.log(highToday); // should be 77
|
||||
console.log(highTomorrow); // should be 80
|
||||
```
|
||||
|
@ -56,12 +56,12 @@ const HIGH_TEMPERATURES = {
|
||||
tomorrow: 80
|
||||
};
|
||||
|
||||
// change code below this line
|
||||
// Only change code below this line
|
||||
|
||||
const highToday = HIGH_TEMPERATURES.today;
|
||||
const highTomorrow = HIGH_TEMPERATURES.tomorrow;
|
||||
|
||||
// change code above this line
|
||||
// Only change code above this line
|
||||
|
||||
console.log(yesterday) // should be not defined
|
||||
console.log(highToday); // should be 77
|
||||
@ -81,12 +81,8 @@ const HIGH_TEMPERATURES = {
|
||||
tomorrow: 80
|
||||
};
|
||||
|
||||
// change code below this line
|
||||
|
||||
const { today: highToday, tomorrow: highTomorrow } = HIGH_TEMPERATURES;
|
||||
|
||||
// change code above this line
|
||||
|
||||
console.log(highToday); // should be 77
|
||||
console.log(highTomorrow); // should be 80
|
||||
```
|
||||
|
@ -61,12 +61,12 @@ const HIGH_TEMPERATURES = {
|
||||
tomorrow: 80
|
||||
};
|
||||
|
||||
// change code below this line
|
||||
// Only change code below this line
|
||||
|
||||
const today = HIGH_TEMPERATURES.today;
|
||||
const tomorrow = HIGH_TEMPERATURES.tomorrow;
|
||||
|
||||
// change code above this line
|
||||
// Only change code above this line
|
||||
|
||||
console.log(yesterday) // should be not defined
|
||||
console.log(today); // should be 77
|
||||
@ -86,12 +86,8 @@ const HIGH_TEMPERATURES = {
|
||||
tomorrow: 80
|
||||
};
|
||||
|
||||
// change code below this line
|
||||
|
||||
const { today, tomorrow } = HIGH_TEMPERATURES;
|
||||
|
||||
// change code above this line
|
||||
|
||||
console.log(yesterday) // should be not defined
|
||||
console.log(today); // should be 77
|
||||
console.log(tomorrow); // should be 80
|
||||
|
@ -67,10 +67,10 @@ const stats = {
|
||||
average: 35.85
|
||||
};
|
||||
|
||||
// use function argument destructuring
|
||||
// change code below this line
|
||||
// Use function argument destructuring
|
||||
// Only change code below this line
|
||||
const half = (stats) => (stats.max + stats.min) / 2.0;
|
||||
// change code above this line
|
||||
// Only change code above this line
|
||||
|
||||
console.log(stats); // should be object
|
||||
console.log(half(stats)); // should be 28.015
|
||||
|
@ -75,9 +75,9 @@ tests:
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
/* Alter code below this line */
|
||||
// Only change code below this line
|
||||
|
||||
/* Alter code above this line */
|
||||
// Only change code above this line
|
||||
|
||||
const thermos = new Thermostat(76); // setting in Fahrenheit scale
|
||||
let temp = thermos.temperature; // 24.44 in C
|
||||
@ -95,8 +95,6 @@ temp = thermos.temperature; // 26 in C
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
|
||||
/* Alter code below this line */
|
||||
class Thermostat {
|
||||
constructor(fahrenheit) {
|
||||
this._tempInCelsius = 5/9 * (fahrenheit - 32);
|
||||
@ -108,7 +106,6 @@ class Thermostat {
|
||||
this._tempInCelsius = newTemp;
|
||||
}
|
||||
}
|
||||
/* Alter code above this line */
|
||||
|
||||
const thermos = new Thermostat(76); // setting in Fahrenheit scale
|
||||
let temp = thermos.temperature; // 24.44 in C
|
||||
|
@ -58,14 +58,14 @@ tests:
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// change code below this line
|
||||
// Only change code below this line
|
||||
const bicycle = {
|
||||
gear: 2,
|
||||
setGear: function(newGear) {
|
||||
this.gear = newGear;
|
||||
}
|
||||
};
|
||||
// change code above this line
|
||||
// Only change code above this line
|
||||
bicycle.setGear(3);
|
||||
console.log(bicycle.gear);
|
||||
```
|
||||
|
@ -54,13 +54,13 @@ tests:
|
||||
```js
|
||||
const createPerson = (name, age, gender) => {
|
||||
"use strict";
|
||||
// change code below this line
|
||||
// Only change code below this line
|
||||
return {
|
||||
name: name,
|
||||
age: age,
|
||||
gender: gender
|
||||
};
|
||||
// change code above this line
|
||||
// Only change code above this line
|
||||
};
|
||||
console.log(createPerson("Zodiac Hasbro", 56, "male")); // returns a proper object
|
||||
```
|
||||
|
Reference in New Issue
Block a user