fixed arrow function with no curly braces failing IIFE test (#38544)

* fixed arrow function with no curly braces failing IIFE test

* added iife 2nd test fix and 3 new solutions
This commit is contained in:
piouson 2020-04-20 10:04:28 +01:00 committed by GitHub
parent d739a0cc5d
commit 2b60f3e61e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -30,9 +30,9 @@ Rewrite the function <code>makeNest</code> and remove its call so instead it's a
```yml
tests:
- text: The function should be anonymous.
testString: assert(/\((function|\(\))(=>|\(\)){/.test(code.replace(/\s/g, "")));
testString: assert(/\((function|\(\))(=>|\(\)){?/.test(code.replace(/\s/g, "")));
- text: Your function should have parentheses at the end of the expression to call it immediately.
testString: assert(/}\)\(\)/.test(code.replace(/\s/g, "")));
testString: assert(/}?\)\(\)$|}\(\)\)$/.test(code.replace(/[\s;]/g, "")));
```
@ -67,4 +67,22 @@ makeNest();
})();
```
```js
(function () {
console.log("A cozy nest is ready");
}());
```
```js
(() => {
console.log("A cozy nest is ready");
})();
```
```js
(() =>
console.log("A cozy nest is ready")
)();
```
</section>