15. implement a simple DOM wrapper to support method chaining like jQuery

JavaScript
Is this helpful ?

easy  - accepted / - tried

I believe you've used jQuery before, we often chain the jQuery methods together to accomplish our goals.

For example, below chained call turns button into a black button with white text.

$('#button')
  .css('color', '#fff')
  .css('backgroundColor', '#000')
  .css('fontWeight', 'bold')

The chaining makes the code simple to read, could you create a simple wrapper $ to make above code work as expected?

The wrapper only needs to have css(propertyName: string, value: any)

Let's try to solve this problem within 10 mintues.

Discuss(37)