After seeing a plethora of websites having the typewriter effect, I knew I had to get my portfolio website some typewriting effect. But doing so, I had to go through a learning curve.
Initially, I had to use Javascript to target one of the headings in html where I wanted the text to display. Then, in the script file, I created an array with multiple phrases I wanted to display. Although I was confused on how to navigate between different phrases, I figured it out by using the condition if(letterIndex<phrases[phraseIndex].length){. Moreover, I used the built-in function 'setTimeout(next function to execute, time for the delay)', to create a realistic writing effect of the characters.
When changing over the phrase, I emptied the content of the previous placeholder that was being concatenated and later ensured the typing effect passed on to the correct phrase with a modulo operator

Top comments (0)