Intermediate
A Fluent Email Builder
EmailBuilder has chainable methods and a subclass HtmlEmailBuilder adds bold. The chain new HtmlEmailBuilder().to(...).subject(...).bold(...) fails, because to and subject return the parent type, which forgets bold.
Fix the two return types so each method keeps the exact class it was called on. The program should print To: asha@x.in | Subject: Hello | <b>Welcome</b>. preview must stay read-only.
What Check tests
- Your code has no type errors
- The console prints the preview line
- A chain that starts with
boldand goes back totoworks previewcannot be assigned
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
Runs in your browser. Your code is saved here.
Press Run to see the page.
Console
Nothing printed yet.