Explorer
Node.js

Implement a `createApp()` with `use(plugin)` and `start()`. Plugins are functions that receive the app context and can add properties or methods.

Problem Statement

Implement a `createApp()` with `use(plugin)` and `start()`. Plugins are functions that receive the app context and can add properties or methods.

Complexity

Time Complexity: -

Space Complexity: -

Hints

šŸ’” Hint 1: Plugins follow a convention: plugin(context) modifies the context. šŸ’” Hint 2: Store plugins and apply them in order on start(). šŸ’” Hint 3: Each plugin receives the app context object and can add/modify properties. āœ… Solution: ```javascript function createApp() { const plugins = []; const context = {}; return { use(plugin) { plugins.push(plugin); }, start() { plugins.forEach(p => p(context)); return context; } }; } ```

Plugin System

Hard
Implement a `createApp()` with `use(plugin)` and `start()`. Plugins are functions that receive the app context and can add properties or methods.
Editor
Loading Editor...
Evaluate code
Output:Click "Run" above to execute and verify your code here.
{"db":"connected","auth":"ready"}