-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
36 lines (36 loc) · 1.02 KB
/
index.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
36
const profile = ["Web Designer","Frontend Developer", "Programmer"];
let work = 0;
let workIndex = 0;
let timeTaken;
const write = document.querySelector("#text");
const cursor = document.querySelector("#cursor");
function Type() {
let text = profile[work].substring(0, workIndex + 1);
write.innerHTML = text;
workIndex++;
if (text === profile[work]) {
cursor.style.display = 'none';
clearInterval(timeTaken);
setTimeout(function () {
timeTaken = setInterval(Delete, 100);
}, 700);
}
}
function Delete() {
let text = profile[work].substring(0, workIndex - 1);
write.innerHTML = text;
workIndex--;
if (text === '') {
clearInterval(timeTaken);
if (work == (profile.length - 1))
work = 0;
else
work++;
workIndex = 0;
setTimeout(function () {
cursor.style.display = 'inline-block';
timeTaken = setInterval(Type, 100);
}, 200);
}
}
timeTaken = setInterval(Type, 100);