fix(curriculum): Consolidated comments for JavaScript Algorithms and Data Structures challenges - part 2 of 4 (#38259)
This commit is contained in:
@@ -63,9 +63,9 @@ tests:
|
||||
|
||||
```js
|
||||
let myArray = ["a", "b", "c", "d"];
|
||||
// change code below this line
|
||||
// Only change code below this line
|
||||
|
||||
//change code above this line
|
||||
// Only change code above this line
|
||||
console.log(myArray);
|
||||
```
|
||||
|
||||
|
@@ -56,14 +56,13 @@ let foods = {
|
||||
grapes: 35,
|
||||
strawberries: 27
|
||||
};
|
||||
// do not change code above this line
|
||||
|
||||
function checkInventory(scannedItem) {
|
||||
// change code below this line
|
||||
// Only change code below this line
|
||||
|
||||
// Only change code above this line
|
||||
}
|
||||
|
||||
// change code below this line to test different cases:
|
||||
console.log(checkInventory("apples"));
|
||||
```
|
||||
|
||||
|
@@ -51,13 +51,12 @@ tests:
|
||||
|
||||
```js
|
||||
function mixedNumbers(arr) {
|
||||
// change code below this line
|
||||
// Only change code below this line
|
||||
|
||||
// change code above this line
|
||||
// Only change code above this line
|
||||
return arr;
|
||||
}
|
||||
|
||||
// do not change code below this line
|
||||
console.log(mixedNumbers(['IV', 5, 'six']));
|
||||
```
|
||||
|
||||
@@ -72,10 +71,8 @@ console.log(mixedNumbers(['IV', 5, 'six']));
|
||||
|
||||
```js
|
||||
function mixedNumbers(arr) {
|
||||
// change code below this line
|
||||
arr.push(7,'VIII',9);
|
||||
arr.unshift('I',2,'three');
|
||||
// change code above this line
|
||||
return arr;
|
||||
}
|
||||
```
|
||||
|
@@ -53,13 +53,12 @@ tests:
|
||||
|
||||
```js
|
||||
function htmlColorNames(arr) {
|
||||
// change code below this line
|
||||
// Only change code below this line
|
||||
|
||||
// change code above this line
|
||||
// Only change code above this line
|
||||
return arr;
|
||||
}
|
||||
|
||||
// do not change code below this line
|
||||
console.log(htmlColorNames(['DarkGoldenRod', 'WhiteSmoke', 'LavenderBlush', 'PaleTurquoise', 'FireBrick']));
|
||||
```
|
||||
|
||||
|
@@ -72,9 +72,9 @@ let foods = {
|
||||
plums: 28
|
||||
};
|
||||
|
||||
// change code below this line
|
||||
// Only change code below this line
|
||||
|
||||
// change code above this line
|
||||
// Only change code above this line
|
||||
|
||||
console.log(foods);
|
||||
```
|
||||
@@ -95,11 +95,9 @@ let foods = {
|
||||
plums: 28
|
||||
};
|
||||
|
||||
// change code below this line
|
||||
foods['bananas'] = 13;
|
||||
foods['grapes'] = 35;
|
||||
foods['strawberries'] = 27;
|
||||
// change code above this line
|
||||
```
|
||||
|
||||
</section>
|
||||
|
@@ -52,12 +52,11 @@ tests:
|
||||
|
||||
```js
|
||||
function quickCheck(arr, elem) {
|
||||
// change code below this line
|
||||
// Only change code below this line
|
||||
|
||||
// change code above this line
|
||||
// Only change code above this line
|
||||
}
|
||||
|
||||
// change code here to test different cases:
|
||||
console.log(quickCheck(['squash', 'onions', 'shallots'], 'mushrooms'));
|
||||
```
|
||||
|
||||
@@ -72,9 +71,7 @@ console.log(quickCheck(['squash', 'onions', 'shallots'], 'mushrooms'));
|
||||
|
||||
```js
|
||||
function quickCheck(arr, elem) {
|
||||
// change code below this line
|
||||
return arr.indexOf(elem) >= 0;
|
||||
// change code above this line
|
||||
}
|
||||
```
|
||||
|
||||
|
@@ -69,9 +69,9 @@ let users = {
|
||||
};
|
||||
|
||||
function isEveryoneHere(obj) {
|
||||
// change code below this line
|
||||
// Only change code below this line
|
||||
|
||||
// change code above this line
|
||||
// Only change code above this line
|
||||
}
|
||||
|
||||
console.log(isEveryoneHere(users));
|
||||
|
@@ -46,11 +46,10 @@ tests:
|
||||
```js
|
||||
function spreadOut() {
|
||||
let fragment = ['to', 'code'];
|
||||
let sentence; // change this line
|
||||
let sentence; // Change this line
|
||||
return sentence;
|
||||
}
|
||||
|
||||
// do not change code below this line
|
||||
console.log(spreadOut());
|
||||
```
|
||||
|
||||
|
@@ -53,15 +53,14 @@ tests:
|
||||
function copyMachine(arr, num) {
|
||||
let newArr = [];
|
||||
while (num >= 1) {
|
||||
// change code below this line
|
||||
// Only change code below this line
|
||||
|
||||
// change code above this line
|
||||
// Only change code above this line
|
||||
num--;
|
||||
}
|
||||
return newArr;
|
||||
}
|
||||
|
||||
// change code here to test different cases:
|
||||
console.log(copyMachine([true, false, true], 2));
|
||||
```
|
||||
|
||||
@@ -85,9 +84,7 @@ const removeJSComments = str => str.replace(/\/\*[\s\S]*?\*\/|\/\/.*$/gm, '');
|
||||
function copyMachine(arr,num){
|
||||
let newArr=[];
|
||||
while(num >=1){
|
||||
// change code below this line
|
||||
newArr.push([...arr]);
|
||||
//change code above this line
|
||||
num--;
|
||||
}
|
||||
return newArr;
|
||||
|
@@ -46,12 +46,12 @@ tests:
|
||||
|
||||
```js
|
||||
function forecast(arr) {
|
||||
// change code below this line
|
||||
// Only change code below this line
|
||||
|
||||
return arr;
|
||||
}
|
||||
|
||||
// do not change code below this line
|
||||
// Only change code above this line
|
||||
console.log(forecast(['cold', 'rainy', 'warm', 'sunny', 'cool', 'thunderstorms']));
|
||||
```
|
||||
|
||||
|
@@ -80,13 +80,13 @@ tests:
|
||||
|
||||
```js
|
||||
let myNestedArray = [
|
||||
// change code below this line
|
||||
// Only change code below this line
|
||||
['unshift', false, 1, 2, 3, 'complex', 'nested'],
|
||||
['loop', 'shift', 6, 7, 1000, 'method'],
|
||||
['concat', false, true, 'spread', 'array'],
|
||||
['mutate', 1327.98, 'splice', 'slice', 'push'],
|
||||
['iterate', 1.3849, 7, '8.4876', 'arbitrary', 'depth']
|
||||
// change code above this line
|
||||
// Only change code above this line
|
||||
];
|
||||
```
|
||||
|
||||
@@ -101,13 +101,11 @@ let myNestedArray = [
|
||||
|
||||
```js
|
||||
let myNestedArray = [
|
||||
// change code below this line
|
||||
['unshift', ['deep', ['deeper', ['deepest']]],false, 1, 2, 3, 'complex', 'nested'],
|
||||
['loop', 'shift', 6, 7, 1000, 'method'],
|
||||
['concat', false, true, 'spread', 'array'],
|
||||
['mutate', 1327.98, 'splice', 'slice', 'push'],
|
||||
['iterate', 1.3849, 7, '8.4876', 'arbitrary', 'depth']
|
||||
// change code above this line
|
||||
];
|
||||
```
|
||||
|
||||
|
@@ -55,9 +55,9 @@ let users = {
|
||||
};
|
||||
|
||||
function getArrayOfUsers(obj) {
|
||||
// change code below this line
|
||||
// Only change code below this line
|
||||
|
||||
// change code above this line
|
||||
// Only change code above this line
|
||||
}
|
||||
|
||||
console.log(getArrayOfUsers(users));
|
||||
|
@@ -58,12 +58,11 @@ tests:
|
||||
|
||||
```js
|
||||
function popShift(arr) {
|
||||
let popped; // change this line
|
||||
let shifted; // change this line
|
||||
let popped; // Change this line
|
||||
let shifted; // Change this line
|
||||
return [shifted, popped];
|
||||
}
|
||||
|
||||
// do not change code below this line
|
||||
console.log(popShift(['challenge', 'is', 'not', 'complete']));
|
||||
```
|
||||
|
||||
@@ -78,8 +77,8 @@ console.log(popShift(['challenge', 'is', 'not', 'complete']));
|
||||
|
||||
```js
|
||||
function popShift(arr) {
|
||||
let popped = arr.pop(); // change this line
|
||||
let shifted = arr.shift(); // change this line
|
||||
let popped = arr.pop(); // Change this line
|
||||
let shifted = arr.shift(); // Change this line
|
||||
return [shifted, popped];
|
||||
}
|
||||
```
|
||||
|
@@ -60,9 +60,9 @@ tests:
|
||||
|
||||
```js
|
||||
const arr = [2, 4, 5, 1, 7, 5, 2, 1];
|
||||
// only change code below this line
|
||||
// Only change code below this line
|
||||
|
||||
// only change code above this line
|
||||
// Only change code above this line
|
||||
console.log(arr);
|
||||
```
|
||||
|
||||
|
@@ -76,7 +76,7 @@ tests:
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
let yourArray; // change this line
|
||||
let yourArray; // Change this line
|
||||
```
|
||||
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user