By the end of this step, the shown word will automatically change every second.

This can be achieved by using setInterval, a browser function which repeatedly calls a function with a fixed delay between each call.

Define a method tickToNextWord bound to the component that will increment this.idx.

Calling this method increments our reactive internal state idx which will schedule an update.

Since you'll use this method with setInterval, an arrow function can be used such that this refers to the component. See the "this" problem for more info.

To setup the interval and clean up the interval, use the standard custom element lifecycle callbacks connectedCallback, and disconnectedCallback.

connectedCallback is invoked when the component is added to the DOM, and disconnectedCallback is invoked when the component is removed from the DOM.

When the word-viewer is attached to the DOM, connectedCallback is invoked and setInterval repeatedly calls this.tickToNextWord every 1000ms, or every second.

The interval ID is stored on this.intervalTimer which does not need to be reactive.

When word-viewer is removed from the DOM, disconnectedCallback is invoked cleaning up the interval, and this.tickToNextWord is no longer called.

The preview should be cycling over individual words.

Lit leverages standard custom element lifecycle callbacks.

If you customize any of the standard custom element lifecycle methods, make sure to call the super implementation so the standard Lit functionality is preserved. See lifecycle docs for more info.