        typeLoop();
          }, pausTime);
          return;
        }

        //move to next char when deleted
        if (isDelete && charIdx === 0) {
          isDelete = false;
          //use modulo so that it can reback at 0
          currTextIdx = (currTextIdx + 1) % texts.length;
        }

        // Deleting is faster (half the speed)
        // Typing is slower
        setTimeout(typeLoop, isDelete ? speed / 2 : speed);
      }
      typeLoop(); // start animation
    </script>
  </body>
</html