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
|
```js
|
||||||
let myArray = ["a", "b", "c", "d"];
|
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);
|
console.log(myArray);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -56,14 +56,13 @@ let foods = {
|
|||||||
grapes: 35,
|
grapes: 35,
|
||||||
strawberries: 27
|
strawberries: 27
|
||||||
};
|
};
|
||||||
// do not change code above this line
|
|
||||||
|
|
||||||
function checkInventory(scannedItem) {
|
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"));
|
console.log(checkInventory("apples"));
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -51,13 +51,12 @@ tests:
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
function mixedNumbers(arr) {
|
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;
|
return arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// do not change code below this line
|
|
||||||
console.log(mixedNumbers(['IV', 5, 'six']));
|
console.log(mixedNumbers(['IV', 5, 'six']));
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -72,10 +71,8 @@ console.log(mixedNumbers(['IV', 5, 'six']));
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
function mixedNumbers(arr) {
|
function mixedNumbers(arr) {
|
||||||
// change code below this line
|
|
||||||
arr.push(7,'VIII',9);
|
arr.push(7,'VIII',9);
|
||||||
arr.unshift('I',2,'three');
|
arr.unshift('I',2,'three');
|
||||||
// change code above this line
|
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -53,13 +53,12 @@ tests:
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
function htmlColorNames(arr) {
|
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;
|
return arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// do not change code below this line
|
|
||||||
console.log(htmlColorNames(['DarkGoldenRod', 'WhiteSmoke', 'LavenderBlush', 'PaleTurquoise', 'FireBrick']));
|
console.log(htmlColorNames(['DarkGoldenRod', 'WhiteSmoke', 'LavenderBlush', 'PaleTurquoise', 'FireBrick']));
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -72,9 +72,9 @@ let foods = {
|
|||||||
plums: 28
|
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);
|
console.log(foods);
|
||||||
```
|
```
|
||||||
@ -95,11 +95,9 @@ let foods = {
|
|||||||
plums: 28
|
plums: 28
|
||||||
};
|
};
|
||||||
|
|
||||||
// change code below this line
|
|
||||||
foods['bananas'] = 13;
|
foods['bananas'] = 13;
|
||||||
foods['grapes'] = 35;
|
foods['grapes'] = 35;
|
||||||
foods['strawberries'] = 27;
|
foods['strawberries'] = 27;
|
||||||
// change code above this line
|
|
||||||
```
|
```
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
@ -52,12 +52,11 @@ tests:
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
function quickCheck(arr, elem) {
|
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'));
|
console.log(quickCheck(['squash', 'onions', 'shallots'], 'mushrooms'));
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -72,9 +71,7 @@ console.log(quickCheck(['squash', 'onions', 'shallots'], 'mushrooms'));
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
function quickCheck(arr, elem) {
|
function quickCheck(arr, elem) {
|
||||||
// change code below this line
|
|
||||||
return arr.indexOf(elem) >= 0;
|
return arr.indexOf(elem) >= 0;
|
||||||
// change code above this line
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -69,9 +69,9 @@ let users = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function isEveryoneHere(obj) {
|
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));
|
console.log(isEveryoneHere(users));
|
||||||
|
@ -46,11 +46,10 @@ tests:
|
|||||||
```js
|
```js
|
||||||
function spreadOut() {
|
function spreadOut() {
|
||||||
let fragment = ['to', 'code'];
|
let fragment = ['to', 'code'];
|
||||||
let sentence; // change this line
|
let sentence; // Change this line
|
||||||
return sentence;
|
return sentence;
|
||||||
}
|
}
|
||||||
|
|
||||||
// do not change code below this line
|
|
||||||
console.log(spreadOut());
|
console.log(spreadOut());
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -53,15 +53,14 @@ tests:
|
|||||||
function copyMachine(arr, num) {
|
function copyMachine(arr, num) {
|
||||||
let newArr = [];
|
let newArr = [];
|
||||||
while (num >= 1) {
|
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--;
|
num--;
|
||||||
}
|
}
|
||||||
return newArr;
|
return newArr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// change code here to test different cases:
|
|
||||||
console.log(copyMachine([true, false, true], 2));
|
console.log(copyMachine([true, false, true], 2));
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -85,9 +84,7 @@ const removeJSComments = str => str.replace(/\/\*[\s\S]*?\*\/|\/\/.*$/gm, '');
|
|||||||
function copyMachine(arr,num){
|
function copyMachine(arr,num){
|
||||||
let newArr=[];
|
let newArr=[];
|
||||||
while(num >=1){
|
while(num >=1){
|
||||||
// change code below this line
|
|
||||||
newArr.push([...arr]);
|
newArr.push([...arr]);
|
||||||
//change code above this line
|
|
||||||
num--;
|
num--;
|
||||||
}
|
}
|
||||||
return newArr;
|
return newArr;
|
||||||
|
@ -46,12 +46,12 @@ tests:
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
function forecast(arr) {
|
function forecast(arr) {
|
||||||
// change code below this line
|
// Only change code below this line
|
||||||
|
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// do not change code below this line
|
// Only change code above this line
|
||||||
console.log(forecast(['cold', 'rainy', 'warm', 'sunny', 'cool', 'thunderstorms']));
|
console.log(forecast(['cold', 'rainy', 'warm', 'sunny', 'cool', 'thunderstorms']));
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -80,13 +80,13 @@ tests:
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
let myNestedArray = [
|
let myNestedArray = [
|
||||||
// change code below this line
|
// Only change code below this line
|
||||||
['unshift', false, 1, 2, 3, 'complex', 'nested'],
|
['unshift', false, 1, 2, 3, 'complex', 'nested'],
|
||||||
['loop', 'shift', 6, 7, 1000, 'method'],
|
['loop', 'shift', 6, 7, 1000, 'method'],
|
||||||
['concat', false, true, 'spread', 'array'],
|
['concat', false, true, 'spread', 'array'],
|
||||||
['mutate', 1327.98, 'splice', 'slice', 'push'],
|
['mutate', 1327.98, 'splice', 'slice', 'push'],
|
||||||
['iterate', 1.3849, 7, '8.4876', 'arbitrary', 'depth']
|
['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
|
```js
|
||||||
let myNestedArray = [
|
let myNestedArray = [
|
||||||
// change code below this line
|
|
||||||
['unshift', ['deep', ['deeper', ['deepest']]],false, 1, 2, 3, 'complex', 'nested'],
|
['unshift', ['deep', ['deeper', ['deepest']]],false, 1, 2, 3, 'complex', 'nested'],
|
||||||
['loop', 'shift', 6, 7, 1000, 'method'],
|
['loop', 'shift', 6, 7, 1000, 'method'],
|
||||||
['concat', false, true, 'spread', 'array'],
|
['concat', false, true, 'spread', 'array'],
|
||||||
['mutate', 1327.98, 'splice', 'slice', 'push'],
|
['mutate', 1327.98, 'splice', 'slice', 'push'],
|
||||||
['iterate', 1.3849, 7, '8.4876', 'arbitrary', 'depth']
|
['iterate', 1.3849, 7, '8.4876', 'arbitrary', 'depth']
|
||||||
// change code above this line
|
|
||||||
];
|
];
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -55,9 +55,9 @@ let users = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function getArrayOfUsers(obj) {
|
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));
|
console.log(getArrayOfUsers(users));
|
||||||
|
@ -58,12 +58,11 @@ tests:
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
function popShift(arr) {
|
function popShift(arr) {
|
||||||
let popped; // change this line
|
let popped; // Change this line
|
||||||
let shifted; // change this line
|
let shifted; // Change this line
|
||||||
return [shifted, popped];
|
return [shifted, popped];
|
||||||
}
|
}
|
||||||
|
|
||||||
// do not change code below this line
|
|
||||||
console.log(popShift(['challenge', 'is', 'not', 'complete']));
|
console.log(popShift(['challenge', 'is', 'not', 'complete']));
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -78,8 +77,8 @@ console.log(popShift(['challenge', 'is', 'not', 'complete']));
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
function popShift(arr) {
|
function popShift(arr) {
|
||||||
let popped = arr.pop(); // change this line
|
let popped = arr.pop(); // Change this line
|
||||||
let shifted = arr.shift(); // change this line
|
let shifted = arr.shift(); // Change this line
|
||||||
return [shifted, popped];
|
return [shifted, popped];
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -60,9 +60,9 @@ tests:
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
const arr = [2, 4, 5, 1, 7, 5, 2, 1];
|
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);
|
console.log(arr);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ tests:
|
|||||||
<div id='js-seed'>
|
<div id='js-seed'>
|
||||||
|
|
||||||
```js
|
```js
|
||||||
let yourArray; // change this line
|
let yourArray; // Change this line
|
||||||
```
|
```
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -54,7 +54,7 @@ var ourData = ourArray[0]; // equals 50
|
|||||||
// Setup
|
// Setup
|
||||||
var myArray = [50,60,70];
|
var myArray = [50,60,70];
|
||||||
|
|
||||||
// Only change code below this line.
|
// Only change code below this line
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ tests:
|
|||||||
// Setup
|
// Setup
|
||||||
var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]];
|
var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]];
|
||||||
|
|
||||||
// Only change code below this line.
|
// Only change code below this line
|
||||||
var myData = myArray[0][0];
|
var myData = myArray[0][0];
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -77,7 +77,7 @@ var testObj = {
|
|||||||
19: "Unitas"
|
19: "Unitas"
|
||||||
};
|
};
|
||||||
|
|
||||||
// Only change code below this line;
|
// Only change code below this line
|
||||||
|
|
||||||
var playerNumber; // Change this Line
|
var playerNumber; // Change this Line
|
||||||
var player = testObj; // Change this Line
|
var player = testObj; // Change this Line
|
||||||
|
@ -59,7 +59,7 @@ var myDog = {
|
|||||||
"friends": ["freeCodeCamp Campers"]
|
"friends": ["freeCodeCamp Campers"]
|
||||||
};
|
};
|
||||||
|
|
||||||
// Only change code below this line.
|
// Only change code below this line
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ var ourDog = {
|
|||||||
"friends": ["everything!"]
|
"friends": ["everything!"]
|
||||||
};
|
};
|
||||||
|
|
||||||
// Only change code below this line.
|
// Only change code below this line
|
||||||
|
|
||||||
var myDog = {
|
var myDog = {
|
||||||
|
|
||||||
|
@ -70,7 +70,6 @@ function testGreaterThan(val) {
|
|||||||
return "10 or Under";
|
return "10 or Under";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change this value to test
|
|
||||||
testGreaterThan(10);
|
testGreaterThan(10);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -56,12 +56,10 @@ var a = 3;
|
|||||||
var b = 17;
|
var b = 17;
|
||||||
var c = 12;
|
var c = 12;
|
||||||
|
|
||||||
// Only modify code below this line
|
// Only change code below this line
|
||||||
|
|
||||||
a = a + 12;
|
a = a + 12;
|
||||||
b = 9 + b;
|
b = 9 + b;
|
||||||
c = c + 7;
|
c = c + 7;
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -49,12 +49,10 @@ var a = 48;
|
|||||||
var b = 108;
|
var b = 108;
|
||||||
var c = 33;
|
var c = 33;
|
||||||
|
|
||||||
// Only modify code below this line
|
// Only change code below this line
|
||||||
|
|
||||||
a = a / 12;
|
a = a / 12;
|
||||||
b = b / 4;
|
b = b / 4;
|
||||||
c = c / 11;
|
c = c / 11;
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -49,13 +49,10 @@ var a = 5;
|
|||||||
var b = 12;
|
var b = 12;
|
||||||
var c = 4.6;
|
var c = 4.6;
|
||||||
|
|
||||||
// Only modify code below this line
|
// Only change code below this line
|
||||||
|
|
||||||
a = a * 5;
|
a = a * 5;
|
||||||
b = 3 * b;
|
b = 3 * b;
|
||||||
c = c * 10;
|
c = c * 10;
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -49,13 +49,10 @@ var a = 11;
|
|||||||
var b = 9;
|
var b = 9;
|
||||||
var c = 3;
|
var c = 3;
|
||||||
|
|
||||||
// Only modify code below this line
|
// Only change code below this line
|
||||||
|
|
||||||
a = a - 6;
|
a = a - 6;
|
||||||
b = b - 15;
|
b = b - 15;
|
||||||
c = c - 1;
|
c = c - 1;
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -60,7 +60,7 @@ for (var i = 10; i > 0; i -= 2) {
|
|||||||
// Setup
|
// Setup
|
||||||
var myArray = [];
|
var myArray = [];
|
||||||
|
|
||||||
// Only change code below this line.
|
// Only change code below this line
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -25,7 +25,7 @@ creates a <code>variable</code> called <code>ourName</code>. In JavaScript we en
|
|||||||
## Instructions
|
## Instructions
|
||||||
<section id='instructions'>
|
<section id='instructions'>
|
||||||
Use the <code>var</code> keyword to create a variable called <code>myName</code>.
|
Use the <code>var</code> keyword to create a variable called <code>myName</code>.
|
||||||
<strong>Hint</strong><br>Look at the <code>ourName</code> example if you get stuck.
|
<strong>Hint</strong><br>Look at the <code>ourName</code> example above if you get stuck.
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
## Tests
|
## Tests
|
||||||
@ -46,10 +46,7 @@ tests:
|
|||||||
<div id='js-seed'>
|
<div id='js-seed'>
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// Example
|
|
||||||
var ourName;
|
|
||||||
|
|
||||||
// Declare myName below this line
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ var myDog = {
|
|||||||
"bark": "woof"
|
"bark": "woof"
|
||||||
};
|
};
|
||||||
|
|
||||||
// Only change code below this line.
|
// Only change code below this line
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -38,7 +38,7 @@ tests:
|
|||||||
<div id='js-seed'>
|
<div id='js-seed'>
|
||||||
|
|
||||||
```js
|
```js
|
||||||
var quotient = 0.0 / 2.0; // Fix this line
|
var quotient = 0.0 / 2.0; // Change this line
|
||||||
```
|
```
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -50,7 +50,7 @@ firstNameLength = firstName.length;
|
|||||||
var lastNameLength = 0;
|
var lastNameLength = 0;
|
||||||
var lastName = "Lovelace";
|
var lastName = "Lovelace";
|
||||||
|
|
||||||
// Only change code below this line.
|
// Only change code below this line
|
||||||
|
|
||||||
lastNameLength = lastName;
|
lastNameLength = lastName;
|
||||||
|
|
||||||
|
@ -42,11 +42,11 @@ tests:
|
|||||||
```js
|
```js
|
||||||
function randomFraction() {
|
function randomFraction() {
|
||||||
|
|
||||||
// Only change code below this line.
|
// Only change code below this line
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// Only change code above this line.
|
// Only change code above this line
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ var randomNumberBetween0and19 = Math.floor(Math.random() * 20);
|
|||||||
|
|
||||||
function randomWholeNum() {
|
function randomWholeNum() {
|
||||||
|
|
||||||
// Only change code below this line.
|
// Only change code below this line
|
||||||
|
|
||||||
return Math.random();
|
return Math.random();
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ function ourRandomRange(ourMin, ourMax) {
|
|||||||
|
|
||||||
ourRandomRange(1, 9);
|
ourRandomRange(1, 9);
|
||||||
|
|
||||||
// Only change code below this line.
|
// Only change code below this line
|
||||||
|
|
||||||
function randomRange(myMin, myMax) {
|
function randomRange(myMin, myMax) {
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ Variables which are used without the <code>var</code> keyword are automatically
|
|||||||
|
|
||||||
## Instructions
|
## Instructions
|
||||||
<section id='instructions'>
|
<section id='instructions'>
|
||||||
Using <code>var</code>, declare a <code>global</code> variable <code>myGlobal</code> outside of any function. Initialize it with a value of <code>10</code>.
|
Using <code>var</code>, declare a global variable named <code>myGlobal</code> outside of any function. Initialize it with a value of <code>10</code>.
|
||||||
Inside function <code>fun1</code>, assign <code>5</code> to <code>oopsGlobal</code> <strong><em>without</em></strong> using the <code>var</code> keyword.
|
Inside function <code>fun1</code>, assign <code>5</code> to <code>oopsGlobal</code> <strong><em>without</em></strong> using the <code>var</code> keyword.
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ tests:
|
|||||||
<div id='js-seed'>
|
<div id='js-seed'>
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// Declare your variable here
|
// Declare the myGlobal variable below this line
|
||||||
|
|
||||||
|
|
||||||
function fun1() {
|
function fun1() {
|
||||||
@ -51,6 +51,7 @@ function fun1() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Only change code above this line
|
// Only change code above this line
|
||||||
|
|
||||||
function fun2() {
|
function fun2() {
|
||||||
var output = "";
|
var output = "";
|
||||||
if (typeof myGlobal != "undefined") {
|
if (typeof myGlobal != "undefined") {
|
||||||
@ -112,15 +113,12 @@ uncapture();
|
|||||||
|
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// Declare your variable here
|
|
||||||
var myGlobal = 10;
|
var myGlobal = 10;
|
||||||
|
|
||||||
function fun1() {
|
function fun1() {
|
||||||
// Assign 5 to oopsGlobal Here
|
|
||||||
oopsGlobal = 5;
|
oopsGlobal = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only change code above this line
|
|
||||||
function fun2() {
|
function fun2() {
|
||||||
var output = "";
|
var output = "";
|
||||||
if(typeof myGlobal != "undefined") {
|
if(typeof myGlobal != "undefined") {
|
||||||
|
@ -57,7 +57,7 @@ for (var i = 0; i < 10; i += 2) {
|
|||||||
// Setup
|
// Setup
|
||||||
var myArray = [];
|
var myArray = [];
|
||||||
|
|
||||||
// Only change code below this line.
|
// Only change code below this line
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -62,7 +62,7 @@ for (var i = 0; i < 5; i++) {
|
|||||||
// Setup
|
// Setup
|
||||||
var myArray = [];
|
var myArray = [];
|
||||||
|
|
||||||
// Only change code below this line.
|
// Only change code below this line
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -53,7 +53,7 @@ tests:
|
|||||||
// Setup
|
// Setup
|
||||||
var myArray = [];
|
var myArray = [];
|
||||||
|
|
||||||
// Only change code below this line.
|
// Only change code below this line
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -51,7 +51,9 @@ tests:
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
function myLocalScope() {
|
function myLocalScope() {
|
||||||
'use strict'; // you shouldn't need to edit this line
|
'use strict';
|
||||||
|
|
||||||
|
// Only change code below this line
|
||||||
|
|
||||||
console.log(myVar);
|
console.log(myVar);
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ var removedFromOurArray = ourArray.pop();
|
|||||||
// Setup
|
// Setup
|
||||||
var myArray = [["John", 23], ["cat", 2]];
|
var myArray = [["John", 23], ["cat", 2]];
|
||||||
|
|
||||||
// Only change code below this line.
|
// Only change code below this line
|
||||||
var removedFromMyArray;
|
var removedFromMyArray;
|
||||||
|
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ ourArray.push(["happy", "joy"]);
|
|||||||
// Setup
|
// Setup
|
||||||
var myArray = [["John", 23], ["cat", 2]];
|
var myArray = [["John", 23], ["cat", 2]];
|
||||||
|
|
||||||
// Only change code below this line.
|
// Only change code below this line
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -45,7 +45,7 @@ var removedFromOurArray = ourArray.shift();
|
|||||||
// Setup
|
// Setup
|
||||||
var myArray = [["John", 23], ["dog", 3]];
|
var myArray = [["John", 23], ["dog", 3]];
|
||||||
|
|
||||||
// Only change code below this line.
|
// Only change code below this line
|
||||||
var removedFromMyArray;
|
var removedFromMyArray;
|
||||||
|
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ var removedFromMyArray;
|
|||||||
```js
|
```js
|
||||||
var myArray = [["John", 23], ["dog", 3]];
|
var myArray = [["John", 23], ["dog", 3]];
|
||||||
|
|
||||||
// Only change code below this line.
|
// Only change code below this line
|
||||||
var removedFromMyArray = myArray.shift();
|
var removedFromMyArray = myArray.shift();
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ ourArray.unshift("Happy");
|
|||||||
var myArray = [["John", 23], ["dog", 3]];
|
var myArray = [["John", 23], ["dog", 3]];
|
||||||
myArray.shift();
|
myArray.shift();
|
||||||
|
|
||||||
// Only change code below this line.
|
// Only change code below this line
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -51,7 +51,7 @@ ourArray[1] = 45; // ourArray now equals [18,45,99].
|
|||||||
// Setup
|
// Setup
|
||||||
var myArray = [18,64,99];
|
var myArray = [18,64,99];
|
||||||
|
|
||||||
// Only change code below this line.
|
// Only change code below this line
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -37,7 +37,7 @@ tests:
|
|||||||
// Example
|
// Example
|
||||||
var ourArray = [["the universe", 42], ["everything", 101010]];
|
var ourArray = [["the universe", 42], ["everything", 101010]];
|
||||||
|
|
||||||
// Only change code below this line.
|
// Only change code below this line
|
||||||
var myArray = [];
|
var myArray = [];
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -59,7 +59,6 @@ function multiplyAll(arr) {
|
|||||||
return product;
|
return product;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Modify values below to test your code
|
|
||||||
multiplyAll([[1,2],[3,4],[5,6,7]]);
|
multiplyAll([[1,2],[3,4],[5,6,7]]);
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -57,7 +57,7 @@ function ourFunctionWithArgs(a, b) {
|
|||||||
}
|
}
|
||||||
ourFunctionWithArgs(10, 5); // Outputs 5
|
ourFunctionWithArgs(10, 5); // Outputs 5
|
||||||
|
|
||||||
// Only change code below this line.
|
// Only change code below this line
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -49,7 +49,7 @@ tests:
|
|||||||
<div id='js-seed'>
|
<div id='js-seed'>
|
||||||
|
|
||||||
```js
|
```js
|
||||||
//Setup
|
// Setup
|
||||||
var contacts = [
|
var contacts = [
|
||||||
{
|
{
|
||||||
"firstName": "Akira",
|
"firstName": "Akira",
|
||||||
|
@ -68,7 +68,6 @@ function abTest(a, b) {
|
|||||||
return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
|
return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change values below to test your code
|
|
||||||
abTest(2,2);
|
abTest(2,2);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -59,12 +59,13 @@ tests:
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
function isLess(a, b) {
|
function isLess(a, b) {
|
||||||
// Fix this code
|
// Only change code below this line
|
||||||
if (a < b) {
|
if (a < b) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
// Only change code above this line
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change these values to test
|
// Change these values to test
|
||||||
|
@ -46,17 +46,20 @@ tests:
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
function nextInLine(arr, item) {
|
function nextInLine(arr, item) {
|
||||||
// Your code here
|
// Only change code below this line
|
||||||
|
|
||||||
|
return item;
|
||||||
|
// Only change code above this line
|
||||||
|
|
||||||
|
|
||||||
return item; // Change this line
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test Setup
|
// Setup
|
||||||
var testArr = [1,2,3,4,5];
|
var testArr = [1,2,3,4,5];
|
||||||
|
|
||||||
// Display Code
|
// Display code
|
||||||
console.log("Before: " + JSON.stringify(testArr));
|
console.log("Before: " + JSON.stringify(testArr));
|
||||||
console.log(nextInLine(testArr, 6)); // Modify this line to test
|
console.log(nextInLine(testArr, 6));
|
||||||
console.log("After: " + JSON.stringify(testArr));
|
console.log("After: " + JSON.stringify(testArr));
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ tests:
|
|||||||
// Example
|
// Example
|
||||||
var ourArray = ["John", 23];
|
var ourArray = ["John", 23];
|
||||||
|
|
||||||
// Only change code below this line.
|
// Only change code below this line
|
||||||
var myArray = [];
|
var myArray = [];
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -62,7 +62,6 @@ function checkObj(checkProp) {
|
|||||||
return "Change Me!";
|
return "Change Me!";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test your code by modifying these values
|
|
||||||
checkObj("gift");
|
checkObj("gift");
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -54,9 +54,8 @@ tests:
|
|||||||
var myStr = "Jello World";
|
var myStr = "Jello World";
|
||||||
|
|
||||||
// Only change code below this line
|
// Only change code below this line
|
||||||
|
myStr[0] = "H"; // Change this line
|
||||||
myStr[0] = "H"; // Fix Me
|
// Only change code above this line
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -39,11 +39,11 @@ tests:
|
|||||||
```js
|
```js
|
||||||
function welcomeToBooleans() {
|
function welcomeToBooleans() {
|
||||||
|
|
||||||
// Only change code below this line.
|
// Only change code below this line
|
||||||
|
|
||||||
return false; // Change this line
|
return false; // Change this line
|
||||||
|
|
||||||
// Only change code above this line.
|
// Only change code above this line
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -55,12 +55,12 @@ tests:
|
|||||||
<div id='js-seed'>
|
<div id='js-seed'>
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// Declarations
|
// Variable declarations
|
||||||
var StUdLyCapVaR;
|
var StUdLyCapVaR;
|
||||||
var properCamelCase;
|
var properCamelCase;
|
||||||
var TitleCaseOver;
|
var TitleCaseOver;
|
||||||
|
|
||||||
// Assignments
|
// Variable assignments
|
||||||
STUDLYCAPVAR = 10;
|
STUDLYCAPVAR = 10;
|
||||||
PRoperCAmelCAse = "A String";
|
PRoperCAmelCAse = "A String";
|
||||||
tITLEcASEoVER = 9000;
|
tITLEcASEoVER = 9000;
|
||||||
|
@ -40,17 +40,15 @@ tests:
|
|||||||
<div id='js-seed'>
|
<div id='js-seed'>
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// Initialize these three variables
|
// Only change code below this line
|
||||||
var a;
|
var a;
|
||||||
var b;
|
var b;
|
||||||
var c;
|
var c;
|
||||||
|
// Only change code above this line
|
||||||
// Do not change code below this line
|
|
||||||
|
|
||||||
a = a + 1;
|
a = a + 1;
|
||||||
b = b + 5;
|
b = b + 5;
|
||||||
c = c + " String!";
|
c = c + " String!";
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -69,7 +69,7 @@ var myDog = {
|
|||||||
"friends": ["freeCodeCamp Campers"]
|
"friends": ["freeCodeCamp Campers"]
|
||||||
};
|
};
|
||||||
|
|
||||||
// Only change code below this line.
|
// Only change code below this line
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -45,7 +45,7 @@ var lastLetterOfFirstName = firstName[firstName.length - 1];
|
|||||||
// Setup
|
// Setup
|
||||||
var lastName = "Lovelace";
|
var lastName = "Lovelace";
|
||||||
|
|
||||||
// Only change code below this line.
|
// Only change code below this line
|
||||||
var lastLetterOfLastName = lastName;
|
var lastLetterOfLastName = lastName;
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ var secondLetterOfFirstName = firstName[1];
|
|||||||
// Setup
|
// Setup
|
||||||
var lastName = "Lovelace";
|
var lastName = "Lovelace";
|
||||||
|
|
||||||
// Only change code below this line.
|
// Only change code below this line
|
||||||
var thirdLetterOfLastName = lastName;
|
var thirdLetterOfLastName = lastName;
|
||||||
|
|
||||||
|
|
||||||
|
@ -70,11 +70,11 @@ function ourTrueOrFalse(isItTrue) {
|
|||||||
// Setup
|
// Setup
|
||||||
function trueOrFalse(wasThatTrue) {
|
function trueOrFalse(wasThatTrue) {
|
||||||
|
|
||||||
// Only change code below this line.
|
// Only change code below this line
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Only change code above this line.
|
// Only change code above this line
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,10 +67,11 @@ tests:
|
|||||||
```js
|
```js
|
||||||
|
|
||||||
|
|
||||||
//Only change code below this line
|
// Only change code below this line
|
||||||
function countdown(n){
|
function countdown(n){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// Only change code above this line
|
||||||
console.log(countdown(5)); // [5, 4, 3, 2, 1]
|
console.log(countdown(5)); // [5, 4, 3, 2, 1]
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -91,7 +92,6 @@ const removeJSComments = str => str.replace(/\/\*[\s\S]*?\*\/|\/\/.*$/gm, '');
|
|||||||
<section id='solution'>
|
<section id='solution'>
|
||||||
|
|
||||||
```js
|
```js
|
||||||
//Only change code below this line
|
|
||||||
function countdown(n){
|
function countdown(n){
|
||||||
return n < 1 ? [] : [n].concat(countdown(n - 1));
|
return n < 1 ? [] : [n].concat(countdown(n - 1));
|
||||||
}
|
}
|
||||||
|
@ -54,8 +54,9 @@ var myAdjective = "big";
|
|||||||
var myVerb = "ran";
|
var myVerb = "ran";
|
||||||
var myAdverb = "quickly";
|
var myAdverb = "quickly";
|
||||||
|
|
||||||
var wordBlanks = ""; // Only change this line;
|
// Only change code below this line
|
||||||
|
var wordBlanks = ""; // Change this line
|
||||||
|
// Only change code above this line
|
||||||
```
|
```
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -61,9 +61,9 @@ tests:
|
|||||||
function countToFive() {
|
function countToFive() {
|
||||||
let firstFive = "12345";
|
let firstFive = "12345";
|
||||||
let len = firstFive.length;
|
let len = firstFive.length;
|
||||||
// Fix the line below
|
// Only change code below this line
|
||||||
for (let i = 1; i <= len; i++) {
|
for (let i = 1; i <= len; i++) {
|
||||||
// Do not alter code below this line
|
// Only change code above this line
|
||||||
console.log(firstFive[i]);
|
console.log(firstFive[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -84,9 +84,9 @@ countToFive();
|
|||||||
function countToFive() {
|
function countToFive() {
|
||||||
let firstFive = "12345";
|
let firstFive = "12345";
|
||||||
let len = firstFive.length;
|
let len = firstFive.length;
|
||||||
// Fix the line below
|
// Only change code below this line
|
||||||
for (let i = 0; i < len; i++) {
|
for (let i = 0; i < len; i++) {
|
||||||
// Do not alter code below this line
|
// Only change code above this line
|
||||||
console.log(firstFive[i]);
|
console.log(firstFive[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,9 +50,9 @@ const makeServerRequest = new Promise((resolve, reject) => {
|
|||||||
let responseFromServer;
|
let responseFromServer;
|
||||||
|
|
||||||
if(responseFromServer) {
|
if(responseFromServer) {
|
||||||
// change this line
|
// Change this line
|
||||||
} else {
|
} else {
|
||||||
// change this line
|
// Change this line
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
@ -62,7 +62,7 @@ tests:
|
|||||||
const arr1 = ['JAN', 'FEB', 'MAR', 'APR', 'MAY'];
|
const arr1 = ['JAN', 'FEB', 'MAR', 'APR', 'MAY'];
|
||||||
let arr2;
|
let arr2;
|
||||||
|
|
||||||
arr2 = []; // change this line
|
arr2 = []; // Change this line
|
||||||
|
|
||||||
console.log(arr2);
|
console.log(arr2);
|
||||||
```
|
```
|
||||||
|
@ -65,7 +65,7 @@ var myConcat = function(arr1, arr2) {
|
|||||||
"use strict";
|
"use strict";
|
||||||
return arr1.concat(arr2);
|
return arr1.concat(arr2);
|
||||||
};
|
};
|
||||||
// test your code
|
|
||||||
console.log(myConcat([1, 2], [3, 4, 5]));
|
console.log(myConcat([1, 2], [3, 4, 5]));
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ const myConcat = (arr1, arr2) => {
|
|||||||
"use strict";
|
"use strict";
|
||||||
return arr1.concat(arr2);
|
return arr1.concat(arr2);
|
||||||
};
|
};
|
||||||
// test your code
|
|
||||||
console.log(myConcat([1, 2], [3, 4, 5]));
|
console.log(myConcat([1, 2], [3, 4, 5]));
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -44,12 +44,11 @@ tests:
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
const squareList = (arr) => {
|
const squareList = (arr) => {
|
||||||
// only change code below this line
|
// Only change code below this line
|
||||||
return arr;
|
return arr;
|
||||||
// only change code above this line
|
// Only change code above this line
|
||||||
};
|
};
|
||||||
|
|
||||||
// test your code
|
|
||||||
const squaredIntegers = squareList([-3, 4.8, 5, 3, -3.2]);
|
const squaredIntegers = squareList([-3, 4.8, 5, 3, -3.2]);
|
||||||
console.log(squaredIntegers);
|
console.log(squaredIntegers);
|
||||||
```
|
```
|
||||||
|
@ -59,7 +59,7 @@ function Dog(name) {
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Modify the code below this line
|
// Only change code below this line
|
||||||
Dog.prototype = {
|
Dog.prototype = {
|
||||||
|
|
||||||
numLegs: 4,
|
numLegs: 4,
|
||||||
|
@ -55,7 +55,10 @@ tests:
|
|||||||
<div id='js-seed'>
|
<div id='js-seed'>
|
||||||
|
|
||||||
```js
|
```js
|
||||||
let chewieRegex = /change/; // Only change this line
|
// Only change code below this line
|
||||||
|
let chewieRegex = /change/; // Change this line
|
||||||
|
// Only change code above this line
|
||||||
|
|
||||||
let result = chewieQuote.match(chewieRegex);
|
let result = chewieQuote.match(chewieRegex);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user