feat(client, learn): add helper functions for common validation operations (#38605)
Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com>
This commit is contained in:
@@ -38,7 +38,7 @@ tests:
|
||||
- text: <code>copyMachine(["it works"], 3)</code> should return <code>[["it works"], ["it works"], ["it works"]]</code>
|
||||
testString: assert.deepEqual(copyMachine(['it works'], 3), [['it works'], ['it works'], ['it works']]);
|
||||
- text: The <code>copyMachine</code> function should utilize the <code>spread operator</code> with array <code>arr</code>
|
||||
testString: assert(removeJSComments(code).match(/\.\.\.arr/));
|
||||
testString: assert(__helpers.removeJSComments(code).match(/\.\.\.arr/));
|
||||
|
||||
```
|
||||
|
||||
@@ -66,15 +66,6 @@ console.log(copyMachine([true, false, true], 2));
|
||||
|
||||
</div>
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
const removeJSComments = str => str.replace(/\/\*[\s\S]*?\*\/|\/\/.*$/gm, '');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
|
@@ -42,13 +42,13 @@ We've initialized an array `arr`. Use `splice()` to remove elements from `arr`,
|
||||
```yml
|
||||
tests:
|
||||
- text: You should not change the original line of <code>const arr = [2, 4, 5, 1, 7, 5, 2, 1];</code>.
|
||||
testString: assert(code.replace(/\s/g, '').match(/constarr=\[2,4,5,1,7,5,2,1\];?/));
|
||||
testString: assert(__helpers.removeWhiteSpace(code).match(/constarr=\[2,4,5,1,7,5,2,1\];?/));
|
||||
- text: <code>arr</code> should only contain elements that sum to <code>10</code>.
|
||||
testString: assert.strictEqual(arr.reduce((a, b) => a + b), 10);
|
||||
- text: Your code should utilize the <code>splice()</code> method on <code>arr</code>.
|
||||
testString: assert(code.replace(/\s/g, '').match(/arr\.splice\(/));
|
||||
testString: assert(__helpers.removeWhiteSpace(code).match(/arr\.splice\(/));
|
||||
- text: The splice should only remove elements from <code>arr</code> and not add any additional elements to <code>arr</code>.
|
||||
testString: assert(!code.replace(/\s/g, '').match(/arr\.splice\(\d+,\d+,\d+.*\)/g));
|
||||
testString: assert(!__helpers.removeWhiteSpace(code).match(/arr\.splice\(\d+,\d+,\d+.*\)/g));
|
||||
```
|
||||
|
||||
</section>
|
||||
|
@@ -39,7 +39,7 @@ tests:
|
||||
- text: <code>myData</code> should be equal to <code>8</code>.
|
||||
testString: assert(myData === 8);
|
||||
- text: You should be using bracket notation to read the correct value from <code>myArray</code>.
|
||||
testString: assert(/myData=myArray\[2\]\[1\]/.test(code.replace(/\s/g, '')));
|
||||
testString: assert(/myData=myArray\[2\]\[1\]/.test(__helpers.removeWhiteSpace(code)));
|
||||
|
||||
```
|
||||
|
||||
|
@@ -37,7 +37,7 @@ tests:
|
||||
- text: You should use a <code>for</code> loop to iterate through <code>myArr</code>.
|
||||
testString: assert(/for\s*\(/g.test(code) && /myArr\s*\[/g.test(code));
|
||||
- text: You should not attempt to directly assign the value 20 to <code>total</code>.
|
||||
testString: assert(!code.replace(/\s/g, '').match(/total[=+-]0*[1-9]+/gm));
|
||||
testString: assert(!__helpers.removeWhiteSpace(code).match(/total[=+-]0*[1-9]+/gm));
|
||||
```
|
||||
|
||||
</section>
|
||||
|
@@ -43,7 +43,7 @@ tests:
|
||||
}
|
||||
assert.throws(declared, ReferenceError);
|
||||
- text: You should add a local <code>myVar</code> variable.
|
||||
testString: assert(/functionmyLocalScope\(\)\{.+(var|let|const)myVar[\s\S]*}/.test(code.replace(/\s/g, '')));
|
||||
testString: assert(/functionmyLocalScope\(\)\{.+(var|let|const)myVar[\s\S]*}/.test(__helpers.removeWhiteSpace(code)));
|
||||
|
||||
|
||||
```
|
||||
|
@@ -57,9 +57,9 @@ tests:
|
||||
- text: <code>sum([2, 3, 4, 5], 3)</code> should equal 9.
|
||||
testString: assert.equal(sum([2, 3, 4, 5], 3), 9);
|
||||
- text: Your code should not rely on any kind of loops (<code>for</code> or <code>while</code> or higher order functions such as <code>forEach</code>, <code>map</code>, <code>filter</code>, or <code>reduce</code>.).
|
||||
testString: assert(!removeJSComments(code).match(/for|while|forEach|map|filter|reduce/g));
|
||||
testString: assert(!__helpers.removeJSComments(code).match(/for|while|forEach|map|filter|reduce/g));
|
||||
- text: You should use recursion to solve this problem.
|
||||
testString: assert(removeJSComments(sum.toString()).match(/sum\(.*\)/g).length > 1);
|
||||
testString: assert(__helpers.removeJSComments(sum.toString()).match(/sum\(.*\)/g).length > 1);
|
||||
```
|
||||
|
||||
</section>
|
||||
@@ -80,16 +80,6 @@ function sum(arr, n) {
|
||||
|
||||
</div>
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
const removeJSComments = str => str.replace(/\/\*[\s\S]*?\*\/|\/\/.*$/gm, '');
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
|
@@ -33,7 +33,7 @@ tests:
|
||||
- text: The variable <code>difference</code> should be equal to 12.
|
||||
testString: assert(difference === 12);
|
||||
- text: You should only subtract one number from 45.
|
||||
testString: assert(/difference=45-33;?/.test(code.replace(/\s/g, '')));
|
||||
testString: assert(/difference=45-33;?/.test(__helpers.removeWhiteSpace(code)));
|
||||
```
|
||||
|
||||
</section>
|
||||
|
@@ -39,7 +39,7 @@ tests:
|
||||
- text: Returned value from <code>addFive</code> should be <code>undefined</code>.
|
||||
testString: assert(addFive() === undefined);
|
||||
- text: Inside the <code>addFive</code> function, you should add <code>5</code> to the <code>sum</code> variable.
|
||||
testString: assert(addFive.toString().replace(/\s/g, '').match(/sum=sum\+5|sum\+=5/));
|
||||
testString: assert(__helpers.removeWhiteSpace(addFive.toString()).match(/sum=sum\+5|sum\+=5/));
|
||||
|
||||
```
|
||||
|
||||
|
@@ -52,9 +52,9 @@ tests:
|
||||
- text: <code>countdown(5)</code> should return <code>[5, 4, 3, 2, 1]</code>
|
||||
testString: assert.deepStrictEqual(countdown(5), [5, 4, 3, 2, 1]);
|
||||
- text: Your code should not rely on any kind of loops (<code>for</code>, <code>while</code> or higher order functions such as <code>forEach</code>, <code>map</code>, <code>filter</code>, and <code>reduce</code>).
|
||||
testString: assert(!removeJSComments(code).match(/for|while|forEach|map|filter|reduce/g));
|
||||
testString: assert(!__helpers.removeJSComments(code).match(/for|while|forEach|map|filter|reduce/g));
|
||||
- text: You should use recursion to solve this problem.
|
||||
testString: assert(removeJSComments(countdown.toString()).match(/countdown\s*\(.+\)/));
|
||||
testString: assert(__helpers.removeJSComments(countdown.toString()).match(/countdown\s*\(.+\)/));
|
||||
```
|
||||
|
||||
</section>
|
||||
@@ -76,15 +76,6 @@ function countdown(n){
|
||||
|
||||
</div>
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
const removeJSComments = str => str.replace(/\/\*[\s\S]*?\*\/|\/\/.*$/gm, '');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
|
@@ -25,9 +25,9 @@ tests:
|
||||
- text: Your function should return an array.
|
||||
testString: assert(Array.isArray(rangeOfNumbers(5, 10)));
|
||||
- text: Your code should not use any loop syntax (<code>for</code> or <code>while</code> or higher order functions such as <code>forEach</code>, <code>map</code>, <code>filter</code>, or <code>reduce</code>).
|
||||
testString: assert(!removeJSComments(code).match(/for|while|forEach|map|filter|reduce/g));
|
||||
testString: assert(!__helpers.removeJSComments(code).match(/for|while|forEach|map|filter|reduce/g));
|
||||
- text: <code>rangeOfNumbers</code> should use recursion (call itself) to solve this challenge.
|
||||
testString: assert(removeJSComments(rangeOfNumbers.toString()).match(/rangeOfNumbers\s*\(.+\)/));
|
||||
testString: assert(__helpers.removeJSComments(rangeOfNumbers.toString()).match(/rangeOfNumbers\s*\(.+\)/));
|
||||
- text: <code>rangeOfNumbers(1, 5)</code> should return <code>[1, 2, 3, 4, 5]</code>.
|
||||
testString: assert.deepStrictEqual(rangeOfNumbers(1, 5), [1, 2, 3, 4, 5]);
|
||||
- text: <code>rangeOfNumbers(6, 9)</code> should return <code>[6, 7, 8, 9]</code>.
|
||||
@@ -51,15 +51,6 @@ function rangeOfNumbers(startNum, endNum) {
|
||||
|
||||
</div>
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
const removeJSComments = str => str.replace(/\/\*[\s\S]*?\*\/|\/\/.*$/gm, '');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
|
@@ -28,9 +28,9 @@ First, use <code>console.log</code> to log the <code>output</code> variable. The
|
||||
```yml
|
||||
tests:
|
||||
- text: You should use <code>console.clear()</code> to clear the browser console.
|
||||
testString: const removeJSComments = code.replace(/\/\*[\s\S]*?\*\/|\/\/.*$/gm, ''); const noSpaces = removeJSComments.replace(/\s/g, ''); assert(noSpaces.match(/console.clear\(\)/));
|
||||
testString: assert(__helpers.removeWhiteSpace(__helpers.removeJSComments(code)).match(/console.clear\(\)/));
|
||||
- text: You should use <code>console.log()</code> to print the <code>output</code> variable.
|
||||
testString: const noSpaces = code.replace(/\s/g, ''); assert(noSpaces.match(/console\.log\(output\)/));
|
||||
testString: assert(__helpers.removeWhiteSpace(code).match(/console\.log\(output\)/));
|
||||
|
||||
```
|
||||
|
||||
@@ -53,8 +53,6 @@ let output = "Get this to log once in the freeCodeCamp console and twice in the
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
|
@@ -33,9 +33,10 @@ Make the promise handle success and failure. If <code>responseFromServer</code>
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>resolve</code> should be called with the expected string when the <code>if</code> condition is <code>true</code>.
|
||||
testString: assert(removeJSComments(code).match(/if\s*\(\s*responseFromServer\s*\)\s*{\s*resolve\s*\(\s*('|"|`)We got the data\1\s*\)(\s*|\s*;\s*)}/g));
|
||||
testString: assert(__helpers.removeJSComments(code).match(/if\s*\(\s*responseFromServer\s*\)\s*{\s*resolve\s*\(\s*('|"|`)We got the data\1\s*\)(\s*|\s*;\s*)}/g));
|
||||
- text: <code>reject</code> should be called with the expected string when the <code>if</code> condition is <code>false</code>.
|
||||
testString: assert(removeJSComments(code).match(/}\s*else\s*{\s*reject\s*\(\s*('|"|`)Data not received\1\s*\)(\s*|\s*;\s*)}/g));
|
||||
testString: assert(__helpers.removeJSComments(code).match(/}\s*else\s*{\s*reject\s*\(\s*('|"|`)Data not received\1\s*\)(\s*|\s*;\s*)}/g));
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
@@ -59,14 +60,6 @@ const makeServerRequest = new Promise((resolve, reject) => {
|
||||
|
||||
</div>
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
const removeJSComments = str => str.replace(/\/\*[\s\S]*?\*\/|\/\/.*$/gm, '');
|
||||
```
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
|
@@ -29,11 +29,11 @@ Add the <code>then</code> method to your promise. Use <code>result</code> as the
|
||||
```yml
|
||||
tests:
|
||||
- text: You should call the <code>then</code> method on the promise.
|
||||
testString: assert(codeWithoutSpaces.match(/(makeServerRequest|\))\.then\(/g));
|
||||
testString: assert(__helpers.removeWhiteSpace(code).match(/(makeServerRequest|\))\.then\(/g));
|
||||
- text: Your <code>then</code> method should have a callback function with <code>result</code> as its parameter.
|
||||
testString: assert(resultIsParameter);
|
||||
- text: You should log <code>result</code> to the console.
|
||||
testString: assert(resultIsParameter && codeWithoutSpaces.match(/\.then\(.*?result.*?console.log\(result\).*?\)/));
|
||||
testString: assert(resultIsParameter && __helpers.removeWhiteSpace(code).match(/\.then\(.*?result.*?console.log\(result\).*?\)/));
|
||||
```
|
||||
|
||||
</section>
|
||||
@@ -61,8 +61,7 @@ const makeServerRequest = new Promise((resolve, reject) => {
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
const codeWithoutSpaces = code.replace(/\s/g, '');
|
||||
const resultIsParameter = /\.then\((function\(result\){|result|\(result\)=>)/.test(codeWithoutSpaces);
|
||||
const resultIsParameter = /\.then\((function\(result\){|result|\(result\)=>)/.test(__helpers.removeWhiteSpace(code));
|
||||
```
|
||||
|
||||
</div>
|
||||
|
@@ -31,11 +31,11 @@ Add the <code>catch</code> method to your promise. Use <code>error</code> as the
|
||||
```yml
|
||||
tests:
|
||||
- text: You should call the <code>catch</code> method on the promise.
|
||||
testString: assert(codeWithoutSpaces.match(/(makeServerRequest|\))\.catch\(/g));
|
||||
testString: assert(__helpers.removeWhiteSpace(code).match(/(makeServerRequest|\))\.catch\(/g));
|
||||
- text: Your <code>catch</code> method should have a callback function with <code>error</code> as its parameter.
|
||||
testString: assert(errorIsParameter);
|
||||
- text: You should log <code>error</code> to the console.
|
||||
testString: assert(errorIsParameter && codeWithoutSpaces.match(/\.catch\(.*?error.*?console.log\(error\).*?\)/));
|
||||
testString: assert(errorIsParameter && __helpers.removeWhiteSpace(code).match(/\.catch\(.*?error.*?console.log\(error\).*?\)/));
|
||||
```
|
||||
|
||||
</section>
|
||||
@@ -67,8 +67,7 @@ makeServerRequest.then(result => {
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
const codeWithoutSpaces = code.replace(/\s/g, '');
|
||||
const errorIsParameter = /\.catch\((function\(error\){|error|\(error\)=>)/.test(codeWithoutSpaces);
|
||||
const errorIsParameter = /\.catch\((function\(error\){|error|\(error\)=>)/.test(__helpers.removeWhiteSpace(code));
|
||||
```
|
||||
|
||||
</div>
|
||||
|
@@ -41,11 +41,11 @@ Replace the two assignments with an equivalent destructuring assignment. It shou
|
||||
```yml
|
||||
tests:
|
||||
- text: You should remove the ES5 assignment syntax.
|
||||
testString: assert(!removeJSComments(code).match(/today\s*=\s*HIGH_TEMPERATURES\.(today|tomorrow)/g))
|
||||
testString: assert(!__helpers.removeJSComments(code).match(/today\s*=\s*HIGH_TEMPERATURES\.(today|tomorrow)/g))
|
||||
- text: You should use destructuring to create the <code>today</code> variable.
|
||||
testString: assert(removeJSComments(code).match(/(var|let|const)\s*{\s*(today[^}]*|[^,]*,\s*today)\s*}\s*=\s*HIGH_TEMPERATURES(;|\s+|\/\/)/g));
|
||||
testString: assert(__helpers.removeJSComments(code).match(/(var|let|const)\s*{\s*(today[^}]*|[^,]*,\s*today)\s*}\s*=\s*HIGH_TEMPERATURES(;|\s+|\/\/)/g));
|
||||
- text: You should use destructuring to create the <code>tomorrow</code> variable.
|
||||
testString: assert(removeJSComments(code).match(/(var|let|const)\s*{\s*(tomorrow[^}]*|[^,]*,\s*tomorrow)\s*}\s*=\s*HIGH_TEMPERATURES(;|\s+|\/\/)/g));
|
||||
testString: assert(__helpers.removeJSComments(code).match(/(var|let|const)\s*{\s*(tomorrow[^}]*|[^,]*,\s*tomorrow)\s*}\s*=\s*HIGH_TEMPERATURES(;|\s+|\/\/)/g));
|
||||
- text: <code>today</code> should be equal to <code>77</code> and <code>tomorrow</code> should be equal to <code>80</code>.
|
||||
testString: assert(today === 77 && tomorrow === 80);
|
||||
|
||||
@@ -74,15 +74,6 @@ const tomorrow = HIGH_TEMPERATURES.tomorrow;
|
||||
|
||||
</div>
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
const removeJSComments = str => str.replace(/\/\*[\s\S]*?\*\/|\/\/.*$/gm, '');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
|
@@ -43,7 +43,7 @@ tests:
|
||||
- text: <code>half(stats)</code> should be <code>28.015</code>
|
||||
testString: assert(half(stats) === 28.015);
|
||||
- text: Destructuring should be used.
|
||||
testString: assert(code.replace(/\s/g, '').match(/half=\({\w+,\w+}\)/));
|
||||
testString: assert(__helpers.removeWhiteSpace(code).match(/half=\({\w+,\w+}\)/));
|
||||
- text: Destructured parameter should be used.
|
||||
testString: assert(!code.match(/stats\.max|stats\.min/));
|
||||
|
||||
|
@@ -37,7 +37,7 @@ tests:
|
||||
- text: <code>Array.slice()</code> should not be used.
|
||||
testString: getUserInput => assert(!getUserInput('index').match(/slice/g));
|
||||
- text: Destructuring on <code>list</code> should be used.
|
||||
testString: assert(code.replace(/\s/g, '').match(/\[(([_$a-z]\w*)?,){1,}\.\.\.arr\]=list/i));
|
||||
testString: assert(__helpers.removeWhiteSpace(code).match(/\[(([_$a-z]\w*)?,){1,}\.\.\.arr\]=list/i));
|
||||
|
||||
```
|
||||
|
||||
|
@@ -40,7 +40,7 @@ tests:
|
||||
- text: The result of <code>sum()</code> should be 0
|
||||
testString: assert(sum() === 0);
|
||||
- text: The <code>sum</code> function should use the <code>...</code> rest parameter on the <code>args</code> parameter.
|
||||
testString: assert(code.replace(/\s/g,'').match(/sum=\(\.\.\.args\)=>/));
|
||||
testString: assert(__helpers.removeWhiteSpace(code).match(/sum=\(\.\.\.args\)=>/));
|
||||
|
||||
```
|
||||
|
||||
|
@@ -42,7 +42,7 @@ Refactor the function <code>setGear</code> inside the object <code>bicycle</code
|
||||
```yml
|
||||
tests:
|
||||
- text: Traditional function expression should not be used.
|
||||
testString: getUserInput => assert(!removeJSComments(code).match(/function/));
|
||||
testString: getUserInput => assert(!__helpers.removeJSComments(code).match(/function/));
|
||||
- text: <code>setGear</code> should be a declarative function.
|
||||
testString: assert(typeof bicycle.setGear === 'function' && code.match(/setGear\s*\(.+\)\s*\{/));
|
||||
- text: <code>bicycle.setGear(48)</code> should change the <code>gear</code> value to 48.
|
||||
@@ -72,15 +72,6 @@ console.log(bicycle.gear);
|
||||
|
||||
</div>
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
const removeJSComments = str => str.replace(/\/\*[\s\S]*?\*\/|\/\/.*$/gm, '');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
|
@@ -24,9 +24,9 @@ tests:
|
||||
- text: <code>squareList</code> should be a <code>function</code>.
|
||||
testString: assert.typeOf(squareList, 'function'), '<code>squareList</code> should be a <code>function</code>';
|
||||
- text: for or while loops or forEach should not be used.
|
||||
testString: assert(!removeJSComments(code).match(/for|while|forEach/g));
|
||||
testString: assert(!__helpers.removeJSComments(code).match(/for|while|forEach/g));
|
||||
- text: <code>map</code>, <code>filter</code>, or <code>reduce</code> should be used.
|
||||
testString: assert(removeJSComments(code).match(/\.(map|filter|reduce)\s*\(/g));
|
||||
testString: assert(__helpers.removeJSComments(code).match(/\.(map|filter|reduce)\s*\(/g));
|
||||
- text: The function should return an <code>array</code>.
|
||||
testString: assert(Array.isArray(squareList([4, 5.6, -9.8, 3.14, 42, 6, 8.34, -2])));
|
||||
- text: <code>squareList([4, 5.6, -9.8, 3.14, 42, 6, 8.34, -2])</code> should return <code>[16, 1764, 36]</code>.
|
||||
@@ -55,14 +55,6 @@ console.log(squaredIntegers);
|
||||
|
||||
</div>
|
||||
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
const removeJSComments = str => str.replace(/\/\*[\s\S]*?\*\/|\/\/.*$/gm, '');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
|
@@ -41,7 +41,7 @@ tests:
|
||||
- text: The <code>watchList</code> variable should not change.
|
||||
testString: assert(watchList[0].Title === "Inception" && watchList[4].Director == "James Cameron");
|
||||
- text: Your code should not use a <code>for</code> loop.
|
||||
testString: assert(!removeJSComments(code).match(/for\s*?\([\s\S]*?\)/));
|
||||
testString: assert(!__helpers.removeJSComments(code).match(/for\s*?\([\s\S]*?\)/));
|
||||
- text: Your code should use the <code>map</code> method.
|
||||
testString: assert(code.match(/\.map/g));
|
||||
- text: <code>ratings</code> should equal <code>[{"title":"Inception","rating":"8.8"},{"title":"Interstellar","rating":"8.6"},{"title":"The Dark Knight","rating":"9.0"},{"title":"Batman Begins","rating":"8.3"},{"title":"Avatar","rating":"7.9"}]</code>.
|
||||
@@ -185,15 +185,6 @@ console.log(JSON.stringify(ratings));
|
||||
|
||||
</div>
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
|
||||
```js
|
||||
const removeJSComments = str => str.replace(/\/\*[\s\S]*?\*\/|\/\/.*$/gm, '');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
|
Reference in New Issue
Block a user