-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
35 lines (33 loc) · 820 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const contentArr = ['Developer','Designer','Freelancer'];
let textString;
let flag =false;
let index =0;
let speed = 400;
let i = 0;
const typing= () => {
if(flag){
textString = contentArr[index].substring(0,i);
document.querySelector('.type').textContent = textString;
i--;
if(textString ===''){
flag = false;
speed *=2;
if (index>=0 && index<2){
index++;
}
else if (index === 2){
index=0;
}
}
}else
{
textString = contentArr[index].substring(0,i);
document.querySelector('.type').textContent = textString;
i++;
if(textString ===contentArr[index]){
flag = true;
speed /= 2.5;
}
}
}
var myVar = setInterval(typing, speed);