fix(client): remove JS comments from user code for tests (#41873)
* Removes comments in js challanges by default * fix local-scope-and-functions test regex * fix all languages * revert language changes * removed unnecessary removeJSComments from challenges * fix challanges in other languages * removed removeJSComments from all challanges
This commit is contained in:
committed by
GitHub
parent
ebe8f99345
commit
db369fbed1
@ -65,7 +65,7 @@ assert.deepEqual(copyMachine(['it works'], 3), [
|
||||
La función `copyMachine` debe utilizar el `spread operator` (operador de propagación) con el arreglo `arr`
|
||||
|
||||
```js
|
||||
assert(__helpers.removeJSComments(code).match(/\.\.\.arr/));
|
||||
assert(code.match(/\.\.\.arr/));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
@ -3,6 +3,7 @@ id: bd7123c9c441eddfaeb4bdef
|
||||
title: Comenta tu código de JavaScript
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/c7ynnTp'
|
||||
removeComments: false
|
||||
forumTopicId: 16783
|
||||
dashedName: comment-your-javascript-code
|
||||
---
|
||||
|
@ -45,7 +45,7 @@ Debes agregar una variable local `myVar`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
/functionmyLocalScope\(\)\{.+(var|let|const)myVar[\s\S]*}/.test(
|
||||
/functionmyLocalScope\(\)\{.*(var|let|const)myVar[\s\S]*}/.test(
|
||||
__helpers.removeWhiteSpace(code)
|
||||
)
|
||||
);
|
||||
|
@ -66,9 +66,7 @@ Tu código no debe depender de ningún tipo de bluces (`for` o `while`) o funcio
|
||||
|
||||
```js
|
||||
assert(
|
||||
!__helpers
|
||||
.removeJSComments(code)
|
||||
.match(/for|while|forEach|map|filter|reduce/g)
|
||||
!code.match(/for|while|forEach|map|filter|reduce/g)
|
||||
);
|
||||
```
|
||||
|
||||
@ -76,7 +74,7 @@ Debes usar recursión para resolver este problema.
|
||||
|
||||
```js
|
||||
assert(
|
||||
__helpers.removeJSComments(sum.toString()).match(/sum\(.*\)/g).length > 1
|
||||
sum.toString().match(/sum\(.*\)/g).length > 1
|
||||
);
|
||||
```
|
||||
|
||||
|
@ -59,9 +59,7 @@ Tu código no debe depender de ningún tipo de bucles (`for`, `while` o funcione
|
||||
|
||||
```js
|
||||
assert(
|
||||
!__helpers
|
||||
.removeJSComments(code)
|
||||
.match(/for|while|forEach|map|filter|reduce/g)
|
||||
!code.match(/for|while|forEach|map|filter|reduce/g)
|
||||
);
|
||||
```
|
||||
|
||||
@ -69,7 +67,7 @@ Debes usar recursión para resolver este problema.
|
||||
|
||||
```js
|
||||
assert(
|
||||
__helpers.removeJSComments(countdown.toString()).match(/countdown\s*\(.+\)/)
|
||||
countdown.toString().match(/countdown\s*\(.+\)/)
|
||||
);
|
||||
```
|
||||
|
||||
|
@ -26,9 +26,7 @@ Tu código no debe utilizar bucles (`for`, `while` o funciones de orden superior
|
||||
|
||||
```js
|
||||
assert(
|
||||
!__helpers
|
||||
.removeJSComments(code)
|
||||
.match(/for|while|forEach|map|filter|reduce/g)
|
||||
!code.match(/for|while|forEach|map|filter|reduce/g)
|
||||
);
|
||||
```
|
||||
|
||||
@ -36,9 +34,7 @@ assert(
|
||||
|
||||
```js
|
||||
assert(
|
||||
__helpers
|
||||
.removeJSComments(rangeOfNumbers.toString())
|
||||
.match(/rangeOfNumbers\s*\(.+\)/)
|
||||
rangeOfNumbers.toString().match(/rangeOfNumbers\s*\(.+\)/)
|
||||
);
|
||||
```
|
||||
|
||||
|
@ -33,7 +33,7 @@ Debes utilizar `console.clear()` para limpiar la consola del navegador.
|
||||
```js
|
||||
assert(
|
||||
__helpers
|
||||
.removeWhiteSpace(__helpers.removeJSComments(code))
|
||||
.removeWhiteSpace(code)
|
||||
.match(/console.clear\(\)/)
|
||||
);
|
||||
```
|
||||
|
@ -32,11 +32,9 @@ Haz una función promesa que maneje el éxito y el fallo. Si `responseFromServer
|
||||
|
||||
```js
|
||||
assert(
|
||||
__helpers
|
||||
.removeJSComments(code)
|
||||
.match(
|
||||
code.match(
|
||||
/if\s*\(\s*responseFromServer\s*\)\s*{\s*resolve\s*\(\s*('|"|`)We got the data\1\s*\)(\s*|\s*;\s*)}/g
|
||||
)
|
||||
)
|
||||
);
|
||||
```
|
||||
|
||||
@ -44,11 +42,9 @@ assert(
|
||||
|
||||
```js
|
||||
assert(
|
||||
__helpers
|
||||
.removeJSComments(code)
|
||||
.match(
|
||||
code.match(
|
||||
/}\s*else\s*{\s*reject\s*\(\s*('|"|`)Data not received\1\s*\)(\s*|\s*;\s*)}/g
|
||||
)
|
||||
)
|
||||
);
|
||||
```
|
||||
|
||||
|
@ -43,9 +43,7 @@ Debes eliminar la sintaxis de asignación ES5.
|
||||
|
||||
```js
|
||||
assert(
|
||||
!__helpers
|
||||
.removeJSComments(code)
|
||||
.match(/today\s*=\s*HIGH_TEMPERATURES\.(today|tomorrow)/g)
|
||||
!code.match(/today\s*=\s*HIGH_TEMPERATURES\.(today|tomorrow)/g)
|
||||
);
|
||||
```
|
||||
|
||||
@ -53,11 +51,9 @@ Debes usar desestructuración para crear la variable `today`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
__helpers
|
||||
.removeJSComments(code)
|
||||
.match(
|
||||
code.match(
|
||||
/(var|let|const)\s*{\s*(today[^}]*|[^,]*,\s*today)\s*}\s*=\s*HIGH_TEMPERATURES(;|\s+|\/\/)/g
|
||||
)
|
||||
)
|
||||
);
|
||||
```
|
||||
|
||||
@ -65,11 +61,9 @@ Debes usar desestructuración para crear la variable `tomorrow`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
__helpers
|
||||
.removeJSComments(code)
|
||||
.match(
|
||||
code.match(
|
||||
/(var|let|const)\s*{\s*(tomorrow[^}]*|[^,]*,\s*tomorrow)\s*}\s*=\s*HIGH_TEMPERATURES(;|\s+|\/\/)/g
|
||||
)
|
||||
)
|
||||
);
|
||||
```
|
||||
|
||||
|
@ -39,7 +39,7 @@ Refactoriza la función `setGear` dentro del objeto `bicycle` para que utilice l
|
||||
La expresión tradicional "function" no debe ser utilizada.
|
||||
|
||||
```js
|
||||
(getUserInput) => assert(!__helpers.removeJSComments(code).match(/function/));
|
||||
(getUserInput) => assert(!code.match(/function/));
|
||||
```
|
||||
|
||||
`setGear` debe ser una función declarativa.
|
||||
|
@ -28,7 +28,7 @@ assert.typeOf(squareList, 'function'),
|
||||
`for`, `while`, y `forEach` no deben ser usados.
|
||||
|
||||
```js
|
||||
assert(!__helpers.removeJSComments(code).match(/for|while|forEach/g));
|
||||
assert(!code.match(/for|while|forEach/g));
|
||||
```
|
||||
|
||||
`map`, `filter`, o `reduce` deben ser usados.
|
||||
@ -36,7 +36,7 @@ assert(!__helpers.removeJSComments(code).match(/for|while|forEach/g));
|
||||
```js
|
||||
assert(
|
||||
__helpers
|
||||
.removeWhiteSpace(__helpers.removeJSComments(code))
|
||||
.removeWhiteSpace(code)
|
||||
.match(/\.(map|filter|reduce)\(/g)
|
||||
);
|
||||
```
|
||||
|
@ -52,7 +52,7 @@ assert(
|
||||
Tu código no debe usar un bucle `for`.
|
||||
|
||||
```js
|
||||
assert(!__helpers.removeJSComments(code).match(/for\s*?\([\s\S]*?\)/));
|
||||
assert(!code.match(/for\s*?\([\s\S]*?\)/));
|
||||
```
|
||||
|
||||
Tu código debe usar el método `map`.
|
||||
|
Reference in New Issue
Block a user