By the end of this step, you'll render one single word from the words property, based on some internal reactive state in our component.
Internal reactive state refers to reactive properties that are not part of the component's public API, therefore don't have an associated attribute.
Define idx, an internal state property that will track which word is shown.
// word-viewer.ts
classWordViewerextendsLitElement {
@state() privateidx=0;
...
}
// word-viewer.js
staticproperties= {
idx: {state: true},
...
};
constructor() {
...
this.idx=0;
}
Then in the render method split the words by the '.' separator, and show the word at the array index of idx % splitWords.length. The % operator will keep the resulting index in the bounds of the splitWords array.