Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 3 additions & 14 deletions exercises/73 - Async Typer/scripts-FINISHED.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,14 @@ function getRandomBetween(min = 20, max = 150, randomNumber = Math.random()) {
return Math.floor(randomNumber * (max - min) + min);
}

// async for of loop
// async function draw(el) {
// const text = el.textContent;
// let soFar = '';
// for (const letter of text) {
// soFar += letter;
// el.textContent = soFar;
// // wait for some amount of time
// const { typeMin, typeMax } = el.dataset;
// const amountOfTimeToWait = getRandomBetween(typeMin, typeMax);
// await wait(amountOfTimeToWait);
// }
// }


// recursion
function draw(el) {
let index = 1;
const text = el.textContent;
const { typeMin, typeMax } = el.dataset;
const typeMin = parseInt(el.dataset.typeMin, 10);
const typeMax = parseInt(el.dataset.typeMax, 10);
async function drawLetter() {
el.textContent = text.slice(0, index);
index += 1;
Expand Down