assets/main.js
//a fun function that displays the text like an adventure game
a fun function that displays the text like an adventure game
a fun function that displays the text like an adventure game
function scrollingText(string) {
  let timerCount = 0
  if (typeof timer !== 'undefined') {
    clearInterval(timer)
  }
  timer = setInterval(() => {
    let currentLetter = string[timerCount]
    gameText.textContent += currentLetter
    timerCount++
    if (string[timerCount] === undefined) {
      clearInterval(timer)
    }
  }, 25)
}
function scrollingText ( string ) { let timerCount = 0 if ( typeof timer !== 'undefined' ) { clearInterval ( timer ) } timer = setInterval ( ( ) => { let currentLetter = string [ timerCount ] gameText . textContent += currentLetter timerCount ++ if ( string [ timerCount ] === undefined ) { clearInterval ( timer ) } } , 25 ) }
a fun function that displays the text like an adventure game
a fun function that displays the text like an adventure game
//set timerCount to zero, this will help look through the string //if the timer is currently in use //clear timer //start timer //pull 1 letter from string //add that letter to the main text element //move to the next letter // if we arrive at last letter //stop the timer