fix(learn): removed use strict from various challenges (#40321)
This commit is contained in:
		| @@ -57,7 +57,6 @@ tests: | ||||
|  | ||||
| ```js | ||||
| function myLocalScope() { | ||||
|   'use strict'; | ||||
|  | ||||
|   // Only change code below this line | ||||
|  | ||||
| @@ -81,7 +80,6 @@ console.log('outside myLocalScope', myVar); | ||||
|  | ||||
| ```js | ||||
| function myLocalScope() { | ||||
|   'use strict'; | ||||
|  | ||||
|   // Only change code below this line | ||||
|   var myVar; | ||||
|   | ||||
| @@ -54,7 +54,6 @@ console.log(printNumTwo()); | ||||
| As you can see, <code>printNumTwo()</code> prints 3 and not 2. This is because the value assigned to <code>i</code> was updated and the <code>printNumTwo()</code> returns the global <code>i</code> and not the value <code>i</code> had when the function was created in the for loop. The <code>let</code> keyword does not follow this behavior: | ||||
|  | ||||
| ```js | ||||
| 'use strict'; | ||||
| let printNumTwo; | ||||
| for (let i = 0; i < 3; i++) { | ||||
|   if (i === 2) { | ||||
| @@ -101,7 +100,6 @@ tests: | ||||
|  | ||||
| ```js | ||||
| function checkScope() { | ||||
|   'use strict'; | ||||
|   var i = 'function scope'; | ||||
|   if (true) { | ||||
|     i = 'block scope'; | ||||
| @@ -123,7 +121,6 @@ function checkScope() { | ||||
|  | ||||
| ```js | ||||
| function checkScope() { | ||||
|   'use strict'; | ||||
|   let i = 'function scope'; | ||||
|   if (true) { | ||||
|     let i = 'block scope'; | ||||
|   | ||||
| @@ -11,7 +11,6 @@ The keyword <code>let</code> is not the only new way to declare variables. In ES | ||||
| <code>const</code> has all the awesome features that <code>let</code> has, with the added bonus that variables declared using <code>const</code> are read-only. They are a constant value, which means that once a variable is assigned with <code>const</code>, it cannot be reassigned. | ||||
|  | ||||
| ```js | ||||
| "use strict"; | ||||
| const FAV_PET = "Cats"; | ||||
| FAV_PET = "Dogs"; // returns error | ||||
| ``` | ||||
| @@ -51,7 +50,6 @@ tests: | ||||
|  | ||||
| ```js | ||||
| function printManyTimes(str) { | ||||
|   "use strict"; | ||||
|  | ||||
|   // Only change code below this line | ||||
|  | ||||
| @@ -77,7 +75,6 @@ printManyTimes("freeCodeCamp"); | ||||
|  | ||||
| ```js | ||||
| function printManyTimes(str) { | ||||
|   "use strict"; | ||||
|  | ||||
|   const SENTENCE = str + " is cool!"; | ||||
|   for (let i = 0; i < str.length; i+=2) { | ||||
|   | ||||
| @@ -12,7 +12,6 @@ Some developers prefer to assign all their variables using <code>const</code> by | ||||
| However, it is important to understand that objects (including arrays and functions) assigned to a variable using <code>const</code> are still mutable. Using the <code>const</code> declaration only prevents reassignment of the variable identifier. | ||||
|  | ||||
| ```js | ||||
| "use strict"; | ||||
| const s = [5, 6, 7]; | ||||
| s = [1, 2, 3]; // throws error, trying to assign a const | ||||
| s[2] = 45; // works just as it would with an array declared with var or let | ||||
| @@ -53,7 +52,6 @@ tests: | ||||
| ```js | ||||
| const s = [5, 7, 2]; | ||||
| function editInPlace() { | ||||
|   'use strict'; | ||||
|   // Only change code below this line | ||||
|  | ||||
|   // Using s = [2, 5, 7] would be invalid | ||||
| @@ -75,7 +73,6 @@ editInPlace(); | ||||
| ```js | ||||
| const s = [5, 7, 2]; | ||||
| function editInPlace() { | ||||
|   'use strict'; | ||||
|   s[0] = 2; | ||||
|   s[1] = 5; | ||||
|   s[2] = 7; | ||||
|   | ||||
| @@ -54,7 +54,6 @@ tests: | ||||
|  | ||||
| ```js | ||||
| function freezeObj() { | ||||
|   'use strict'; | ||||
|   const MATH_CONSTANTS = { | ||||
|     PI: 3.14 | ||||
|   }; | ||||
| @@ -83,7 +82,6 @@ const PI = freezeObj(); | ||||
|  | ||||
| ```js | ||||
| function freezeObj() { | ||||
|   'use strict'; | ||||
|   const MATH_CONSTANTS = { | ||||
|     PI: 3.14 | ||||
|   }; | ||||
|   | ||||
| @@ -67,7 +67,6 @@ tests: | ||||
|  | ||||
| ```js | ||||
| var magic = function() { | ||||
|   "use strict"; | ||||
|   return new Date(); | ||||
| }; | ||||
| ``` | ||||
| @@ -83,7 +82,6 @@ var magic = function() { | ||||
|  | ||||
| ```js | ||||
| const magic = () => { | ||||
|   "use strict"; | ||||
|   return new Date(); | ||||
| }; | ||||
| ``` | ||||
|   | ||||
| @@ -51,7 +51,6 @@ tests: | ||||
| ```js | ||||
| const source = [1,2,3,4,5,6,7,8,9,10]; | ||||
| function removeFirstTwo(list) { | ||||
|   "use strict"; | ||||
|   // Only change code below this line | ||||
|   const arr = list; // Change this line | ||||
|   // Only change code above this line | ||||
| @@ -73,7 +72,6 @@ const arr = removeFirstTwo(source); | ||||
| ```js | ||||
| const source = [1,2,3,4,5,6,7,8,9,10]; | ||||
| function removeFirstTwo(list) { | ||||
|   "use strict"; | ||||
|   const [, , ...arr] = list; | ||||
|   return arr; | ||||
| } | ||||
|   | ||||
| @@ -64,7 +64,6 @@ tests: | ||||
|  | ||||
| ```js | ||||
| var myConcat = function(arr1, arr2) { | ||||
|   "use strict"; | ||||
|   return arr1.concat(arr2); | ||||
| }; | ||||
|  | ||||
| @@ -82,7 +81,6 @@ console.log(myConcat([1, 2], [3, 4, 5])); | ||||
|  | ||||
| ```js | ||||
| const myConcat = (arr1, arr2) =>  { | ||||
|   "use strict"; | ||||
|   return arr1.concat(arr2); | ||||
| }; | ||||
|  | ||||
|   | ||||
| @@ -53,7 +53,6 @@ tests: | ||||
|  | ||||
| ```js | ||||
| const createPerson = (name, age, gender) => { | ||||
|   "use strict"; | ||||
|   // Only change code below this line | ||||
|   return { | ||||
|     name: name, | ||||
| @@ -75,7 +74,6 @@ const createPerson = (name, age, gender) => { | ||||
|  | ||||
| ```js | ||||
| const createPerson = (name, age, gender) => { | ||||
|   "use strict"; | ||||
|   return { | ||||
|     name, | ||||
|     age, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user