13. Build Template Engine

Implement a function `buildTemplateEngine(template, data)` that replaces placeholders in a string with values from a data object. Placeholders use double curly braces like `{{key}}`. Keys can be nested, e.g., `user.name`. If a key doesn't exist, replace it with an empty string.

Examples:

Input: buildTemplateEngine("Hello {{user.name}}, you have {{user.notifications}} notifications.", { user: { name: "Alice", notifications: 5 } })
Output: Hello Alice, you have 5 notifications.
Explanation: Replaces nested keys with their values from the data object.
Input: buildTemplateEngine("Hi {{user.firstName}} {{user.lastName}}!", { user: { firstName: "Bob" } })
Output: Hi Bob !
Explanation: Missing keys replaced with empty strings.
Input: buildTemplateEngine("Missing: {{missing.key}}.", {})
Output: Missing: .
Explanation: Handles missing keys gracefully.
SolutionJavaScript
Test Results
Click "Run Code" to test your solution