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:
@ -30,9 +30,9 @@ Rewrite the function <code>makeNest</code> and remove its call so instead it's a
|
|||||||
```yml
|
```yml
|
||||||
tests:
|
tests:
|
||||||
- text: The function should be anonymous.
|
- 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.
|
- 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>
|
</section>
|
||||||
|
Reference in New Issue
Block a user