Swap a word in the DOM from an array of words
There is no way to remove the behavior. This is usually bad design.
Since there is no way to remove behavior, swapWords() as a function is unneeded: you will never call it twice. It would only make sense defining it as a function if it could be called on different elements.
The initial state of the cycle is undefined and/or inconsistent: since the first swap only occurs after 2s, until then the initial content of the span will be displayed (WEBDESIGNER). Then it will be swapped with... WEBDESIGNER. Either leave the span empty and explicitly call a swap round on initialisation, or push the initial contents of the span on top of the stack of words. Otherwise it's not a cycle, it's a "weird start, then a cycle".
if(i == words.length){ - ok, you defined words as const so this is safe. But it's a bad habit to develop to write code like this: if words was variable between rounds, as it got trimmed from, say, 6 items to 4, and i would be 5, the condition would not be triggered anymore, and also not checked before access. So it would just go on to infinity. The responsible way to write code is always update and bound-check any state vars in a synchronous matter, which means BEFORE using them (i.e. before swappingWord.textContent = words[i].toUpperCase();), not at the end of the round for the next async round. Also always use &gt;=words.length not ==words.length, as a coding habit. Always test for valid/invalid condition, not edge condition. In case you decide later to make words list variable, the == condition will automatically introduce a bug. &gt;= won't. The remarks of this point don't qualify as bad code (it works as long as you don't change initial assumptions), it's just bad style. Get rid of it before you get used to it :)