fix(learn): updated tests and deleted old sample code (#38450)

pull/38476/head
Randell Dawson 2020-03-26 10:42:18 -07:00 committed by GitHub
parent 28d363e65a
commit 1fdb691996
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 6 additions and 40 deletions

View File

@ -85,10 +85,6 @@ var myStr = "Learning to code is ";
```js
var anAdjective = "awesome!";
var ourStr = "freeCodeCamp is ";
ourStr += anAdjective;
var someAdjective = "neat";
var myStr = "Learning to code is ";
myStr += someAdjective;

View File

@ -39,7 +39,7 @@ tests:
- text: <code>myStr</code> should have a value of <code>This is the start. This is the end.</code>
testString: assert(myStr === "This is the start. This is the end.");
- text: You should use the <code>+</code> operator to build <code>myStr</code>.
testString: assert(code.match(/(["']).*(["'])\s*\+\s*(["']).*(["'])/g).length > 1);
testString: assert(code.match(/(["']).*\1\s*\+\s*(["']).*\2/g));
- text: <code>myStr</code> should be created using the <code>var</code> keyword.
testString: assert(/var\s+myStr/.test(code));
- text: You should assign the result to the <code>myStr</code> variable.
@ -84,7 +84,6 @@ var myStr; // Only change this line
```js
var ourStr = "I come first. " + "I come second.";
var myStr = "This is the start. " + "This is the end.";
```

View File

@ -34,7 +34,7 @@ tests:
- text: <code>myStr</code> should have a value of <code>This is the first sentence. This is the second sentence.</code>
testString: assert(myStr === "This is the first sentence. This is the second sentence.");
- text: You should use the <code>+=</code> operator to build <code>myStr</code>.
testString: assert(code.match(/\w\s*\+=\s*["']/g).length > 1 && code.match(/\w\s*\=\s*["']/g).length > 1);
testString: assert(code.match(/myStr\s*\+=\s*(["']).*\1/g));
```
@ -79,9 +79,6 @@ var myStr;
```js
var ourStr = "I come first. ";
ourStr += "I come second.";
var myStr = "This is the first sentence. ";
myStr += "This is the second sentence.";
```

View File

@ -34,7 +34,7 @@ Push the odd numbers from 9 through 1 to <code>myArray</code> using a <code>for<
```yml
tests:
- text: You should be using a <code>for</code> loop for this.
testString: assert(code.match(/for\s*\(/g).length > 1);
testString: assert(/for\s*\([^)]+?\)/.test(code));
- text: You should be using the array method <code>push</code>.
testString: assert(code.match(/myArray.push/));
- text: <code>myArray</code> should equal <code>[9,7,5,3,1]</code>.
@ -77,10 +77,6 @@ if(typeof myArray !== "undefined"){(function(){return myArray;})();}
```js
var ourArray = [];
for (var i = 10; i > 0; i -= 2) {
ourArray.push(i);
}
var myArray = [];
for (var i = 9; i > 0; i -= 2) {
myArray.push(i);

View File

@ -52,7 +52,7 @@ tests:
- text: You should delete the property <code>"tails"</code> from <code>myDog</code>.
testString: assert(typeof myDog === "object" && myDog.tails === undefined);
- text: You should not modify the <code>myDog</code> setup.
testString: 'assert(code.match(/"tails": 1/g).length > 1);'
testString: 'assert(code.match(/"tails": 1/g).length > 0);'
```
@ -97,13 +97,6 @@ var myDog = {
```js
var ourDog = {
"name": "Camper",
"legs": 4,
"tails": 1,
"friends": ["everything!"],
"bark": "bow-wow"
};
var myDog = {
"name": "Happy Coder",
"legs": 4,

View File

@ -60,10 +60,6 @@ lastNameLength = lastName;
```js
var firstNameLength = 0;
var firstName = "Ada";
firstNameLength = firstName.length;
var lastNameLength = 0;
var lastName = "Lovelace";
lastNameLength = lastName.length;

View File

@ -33,7 +33,7 @@ Push the odd numbers from 1 through 9 to <code>myArray</code> using a <code>for<
```yml
tests:
- text: You should be using a <code>for</code> loop for this.
testString: assert(code.match(/for\s*\(/g).length > 1);
testString: assert(/for\s*\([^)]+?\)/.test(code));
- text: <code>myArray</code> should equal <code>[1,3,5,7,9]</code>.
testString: assert.deepEqual(myArray, [1,3,5,7,9]);
@ -74,10 +74,6 @@ if(typeof myArray !== "undefined"){(function(){return myArray;})();}
```js
var ourArray = [];
for (var i = 0; i < 10; i += 2) {
ourArray.push(i);
}
var myArray = [];
for (var i = 1; i < 10; i += 2) {
myArray.push(i);

View File

@ -38,7 +38,7 @@ Use a <code>for</code> loop to work to push the values 1 through 5 onto <code>my
```yml
tests:
- text: You should be using a <code>for</code> loop for this.
testString: assert(code.match(/for\s*\(/g).length > 1);
testString: assert(/for\s*\([^)]+?\)/.test(code));
- text: <code>myArray</code> should equal <code>[1,2,3,4,5]</code>.
testString: assert.deepEqual(myArray, [1,2,3,4,5]);
@ -79,10 +79,6 @@ if (typeof myArray !== "undefined"){(function(){return myArray;})();}
```js
var ourArray = [];
for (var i = 0; i < 5; i++) {
ourArray.push(i);
}
var myArray = [];
for (var i = 1; i < 6; i++) {
myArray.push(i);

View File

@ -74,9 +74,6 @@ var secondToLastLetterOfLastName = lastName; // Change this line
```js
var firstName = "Ada";
var thirdToLastLetterOfFirstName = firstName[firstName.length - 3];
var lastName = "Lovelace";
var secondToLastLetterOfLastName = lastName[lastName.length - 2];
```