* Use dfn tags * remove misused <dfn> tags * Revert "remove misused <dfn> tags" This reverts commit b24968a96810f618d831410ac90a0bc452ebde50. * Update curriculum/challenges/english/01-responsive-web-design/basic-html-and-html5/fill-in-the-blank-with-placeholder-text.english.md Co-Authored-By: Randell Dawson <5313213+RandellDawson@users.noreply.github.com> * Make "array" lowercase Co-Authored-By: Randell Dawson <5313213+RandellDawson@users.noreply.github.com> * Fix dfn usage * Address last dfn tags
1.5 KiB
1.5 KiB
id, title, challengeType, forumTopicId
id | title | challengeType | forumTopicId |
---|---|---|---|
587d7db2367417b2b2512b8b | Understand the Immediately Invoked Function Expression (IIFE) | 1 | 301328 |
Description
(function () {
console.log("Chirp, chirp!");
})(); // this is an anonymous function expression that executes right away
// Outputs "Chirp, chirp!" immediately
Note that the function has no name and is not stored in a variable. The two parentheses () at the end of the function expression cause it to be immediately executed or invoked. This pattern is known as an immediately invoked function expression or IIFE.
Instructions
makeNest
and remove its call so instead it's an anonymous immediately invoked function expression (IIFE).
Tests
tests:
- text: The function should be anonymous.
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, "")));
Challenge Seed
function makeNest() {
console.log("A cozy nest is ready");
}
makeNest();
Solution
(function () {
console.log("A cozy nest is ready");
})();