fix(learn): updated tests and deleted old sample code (#38450)
This commit is contained in:
		| @@ -85,10 +85,6 @@ var myStr = "Learning to code is "; | |||||||
|  |  | ||||||
|  |  | ||||||
| ```js | ```js | ||||||
| var anAdjective = "awesome!"; |  | ||||||
| var ourStr = "freeCodeCamp is "; |  | ||||||
| ourStr += anAdjective; |  | ||||||
|  |  | ||||||
| var someAdjective = "neat"; | var someAdjective = "neat"; | ||||||
| var myStr = "Learning to code is "; | var myStr = "Learning to code is "; | ||||||
| myStr += someAdjective; | myStr += someAdjective; | ||||||
|   | |||||||
| @@ -39,7 +39,7 @@ tests: | |||||||
|   - text: <code>myStr</code> should have a value of <code>This is the start. This is the end.</code> |   - 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."); |     testString: assert(myStr === "This is the start. This is the end."); | ||||||
|   - text: You should use the <code>+</code> operator to build <code>myStr</code>. |   - 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. |   - text: <code>myStr</code> should be created using the <code>var</code> keyword. | ||||||
|     testString: assert(/var\s+myStr/.test(code)); |     testString: assert(/var\s+myStr/.test(code)); | ||||||
|   - text: You should assign the result to the <code>myStr</code> variable. |   - text: You should assign the result to the <code>myStr</code> variable. | ||||||
| @@ -84,7 +84,6 @@ var myStr; // Only change this line | |||||||
|  |  | ||||||
|  |  | ||||||
| ```js | ```js | ||||||
| var ourStr = "I come first. " + "I come second."; |  | ||||||
| var myStr = "This is the start. " + "This is the end."; | var myStr = "This is the start. " + "This is the end."; | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
|   | |||||||
| @@ -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> |   - 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."); |     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>. |   - 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 | ```js | ||||||
| var ourStr = "I come first. "; |  | ||||||
| ourStr += "I come second."; |  | ||||||
|  |  | ||||||
| var myStr = "This is the first sentence. "; | var myStr = "This is the first sentence. "; | ||||||
| myStr += "This is the second sentence."; | myStr += "This is the second sentence."; | ||||||
| ``` | ``` | ||||||
|   | |||||||
| @@ -34,7 +34,7 @@ Push the odd numbers from 9 through 1 to <code>myArray</code> using a <code>for< | |||||||
| ```yml | ```yml | ||||||
| tests: | tests: | ||||||
|   - text: You should be using a <code>for</code> loop for this. |   - 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>. |   - text: You should be using the array method <code>push</code>. | ||||||
|     testString: assert(code.match(/myArray.push/)); |     testString: assert(code.match(/myArray.push/)); | ||||||
|   - text: <code>myArray</code> should equal <code>[9,7,5,3,1]</code>. |   - 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 | ```js | ||||||
| var ourArray = []; |  | ||||||
| for (var i = 10; i > 0; i -= 2) { |  | ||||||
|   ourArray.push(i); |  | ||||||
| } |  | ||||||
| var myArray = []; | var myArray = []; | ||||||
| for (var i = 9; i > 0; i -= 2) { | for (var i = 9; i > 0; i -= 2) { | ||||||
|   myArray.push(i); |   myArray.push(i); | ||||||
|   | |||||||
| @@ -52,7 +52,7 @@ tests: | |||||||
|   - text: You should delete the property <code>"tails"</code> from <code>myDog</code>. |   - text: You should delete the property <code>"tails"</code> from <code>myDog</code>. | ||||||
|     testString: assert(typeof myDog === "object" && myDog.tails === undefined); |     testString: assert(typeof myDog === "object" && myDog.tails === undefined); | ||||||
|   - text: You should not modify the <code>myDog</code> setup. |   - 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 | ```js | ||||||
| var ourDog = { |  | ||||||
|   "name": "Camper", |  | ||||||
|   "legs": 4, |  | ||||||
|   "tails": 1, |  | ||||||
|   "friends": ["everything!"], |  | ||||||
|   "bark": "bow-wow" |  | ||||||
| }; |  | ||||||
| var myDog = { | var myDog = { | ||||||
|   "name": "Happy Coder", |   "name": "Happy Coder", | ||||||
|   "legs": 4, |   "legs": 4, | ||||||
|   | |||||||
| @@ -60,10 +60,6 @@ lastNameLength = lastName; | |||||||
|  |  | ||||||
|  |  | ||||||
| ```js | ```js | ||||||
| var firstNameLength = 0; |  | ||||||
| var firstName = "Ada"; |  | ||||||
| firstNameLength = firstName.length; |  | ||||||
|  |  | ||||||
| var lastNameLength = 0; | var lastNameLength = 0; | ||||||
| var lastName = "Lovelace"; | var lastName = "Lovelace"; | ||||||
| lastNameLength = lastName.length; | lastNameLength = lastName.length; | ||||||
|   | |||||||
| @@ -33,7 +33,7 @@ Push the odd numbers from 1 through 9 to <code>myArray</code> using a <code>for< | |||||||
| ```yml | ```yml | ||||||
| tests: | tests: | ||||||
|   - text: You should be using a <code>for</code> loop for this. |   - 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>. |   - text: <code>myArray</code> should equal <code>[1,3,5,7,9]</code>. | ||||||
|     testString: assert.deepEqual(myArray, [1,3,5,7,9]); |     testString: assert.deepEqual(myArray, [1,3,5,7,9]); | ||||||
|  |  | ||||||
| @@ -74,10 +74,6 @@ if(typeof myArray !== "undefined"){(function(){return myArray;})();} | |||||||
|  |  | ||||||
|  |  | ||||||
| ```js | ```js | ||||||
| var ourArray = []; |  | ||||||
| for (var i = 0; i < 10; i += 2) { |  | ||||||
|   ourArray.push(i); |  | ||||||
| } |  | ||||||
| var myArray = []; | var myArray = []; | ||||||
| for (var i = 1; i < 10; i += 2) { | for (var i = 1; i < 10; i += 2) { | ||||||
|   myArray.push(i); |   myArray.push(i); | ||||||
|   | |||||||
| @@ -38,7 +38,7 @@ Use a <code>for</code> loop to work to push the values 1 through 5 onto <code>my | |||||||
| ```yml | ```yml | ||||||
| tests: | tests: | ||||||
|   - text: You should be using a <code>for</code> loop for this. |   - 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>. |   - text: <code>myArray</code> should equal <code>[1,2,3,4,5]</code>. | ||||||
|     testString: assert.deepEqual(myArray, [1,2,3,4,5]); |     testString: assert.deepEqual(myArray, [1,2,3,4,5]); | ||||||
|  |  | ||||||
| @@ -79,10 +79,6 @@ if (typeof myArray !== "undefined"){(function(){return myArray;})();} | |||||||
|  |  | ||||||
|  |  | ||||||
| ```js | ```js | ||||||
| var ourArray = []; |  | ||||||
| for (var i = 0; i < 5; i++) { |  | ||||||
|   ourArray.push(i); |  | ||||||
| } |  | ||||||
| var myArray = []; | var myArray = []; | ||||||
| for (var i = 1; i < 6; i++) { | for (var i = 1; i < 6; i++) { | ||||||
|   myArray.push(i); |   myArray.push(i); | ||||||
|   | |||||||
| @@ -74,9 +74,6 @@ var secondToLastLetterOfLastName = lastName; // Change this line | |||||||
|  |  | ||||||
|  |  | ||||||
| ```js | ```js | ||||||
| var firstName = "Ada"; |  | ||||||
| var thirdToLastLetterOfFirstName = firstName[firstName.length - 3]; |  | ||||||
|  |  | ||||||
| var lastName = "Lovelace"; | var lastName = "Lovelace"; | ||||||
| var secondToLastLetterOfLastName = lastName[lastName.length - 2]; | var secondToLastLetterOfLastName = lastName[lastName.length - 2]; | ||||||
| ``` | ``` | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user