You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
425 B
22 lines
425 B
const textEl = document.getElementById('text')
|
|
const speedEl = document.getElementById('speed')
|
|
const text = 'We Love Programming!'
|
|
let idx = 1
|
|
let speed = 300 / speedEl.value
|
|
|
|
writeText()
|
|
|
|
function writeText() {
|
|
textEl.innerText = text.slice(0, idx)
|
|
|
|
idx++
|
|
|
|
if(idx > text.length) {
|
|
idx = 1
|
|
}
|
|
|
|
setTimeout(writeText, speed)
|
|
}
|
|
|
|
|
|
speedEl.addEventListener('input', (e) => speed = 300 / e.target.value) |