-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
37 lines (33 loc) · 849 Bytes
/
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
37
var happyI = 0;
var motherI = 0;
var dayI = 0;
var happy = 'Happy';
var mother = "Mother's";
var day = 'Day!';
var speed = 500; /* The speed/duration of the effect in milliseconds */
async function typeWriter() {
await typeHappy();
await typeMother();
await typeDay();
}
async function typeHappy() {
if (happyI < happy.length) {
document.getElementById("happy").innerHTML += happy.charAt(happyI);
happyI++;
await setTimeout(typeHappy, speed);
}
}
async function typeMother() {
if (motherI < mother.length) {
document.getElementById("mother").innerHTML += mother.charAt(motherI);
motherI++;
await setTimeout(typeMother, speed);
}
}
async function typeDay() {
if (dayI < day.length) {
document.getElementById("day").innerHTML += day.charAt(dayI);
dayI++;
await setTimeout(typeDay, speed);
}
}