Practice
JavaScriptData StructuresReactConcepts
Sign in
← Back to problems

Immediately Invoked Function

A Closer Look at Functionseasy

Course · Section 10: A Closer Look at Functions · Lecture 143: Immediately Invoked Function Expressions (IIFE)

Implement `iifeResult(n)` that computes `n * 2` inside an immediately invoked function expression (IIFE) and returns it.

Sample tests

Input: iifeResult(4)
Output: 8
Input: iifeResult(0)
Output: 0

+ 1 hidden test run on Submit.

Hints

Common pitfalls
  • Forgetting the trailing () never runs the function.
Approach & explanation (try first)

The function expression runs immediately and returns its result.

Loading...
⌘/Ctrl + Enter

Run your code to see results.