-
Notifications
You must be signed in to change notification settings - Fork 0
/
code.js
38 lines (31 loc) · 826 Bytes
/
code.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
38
const label = document.getElementById("word")
const textInArray = ["macaco", "tornozelo", "tubo", "ganhou"]
let teste = ["moyses", "teste"]
let interval = 1000
function changeWord(newWord) {
label.innerText = newWord
}
function play(){
getText();
getInterval()
let counter = 0
const timer = setInterval(() => {
changeWord(teste[counter])
console.log(counter)
counter++
if (counter == teste.length) {
clearInterval(timer)
}
}, interval);
}
function getText(){
let text = document.forms["principal"]["ftext"].value;
teste = text.split(" ")
}
function getInterval(){
let number = document.forms["principal"]["fnumber"].value;
const newInterval = parseInt(number)
if (!isNaN(newInterval)) {
interval = number
}
}