-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
79 lines (70 loc) · 1.64 KB
/
Copy pathapp.js
File metadata and controls
79 lines (70 loc) · 1.64 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
var wordfall = [
"apple",
"orange",
"mango",
"sweet",
"banana",
"tree",
"shoe",
"love",
"friends",
"bread",
"clothes",
"market",
"jet",
"made",
"great",
"ocean",
"country",
"market",
"history",
"geography",
"science",
"google",
"brain",
"spine",
"nervous"
];
/// random words generation in array
Array.prototype.random = function() {
return this[Math.floor(Math.random() * this.length)];
};
var m = wordfall.random();
var j = wordfall.random();
var k = wordfall.random();
var l = wordfall.random();
// changing words in div
function autoRefreshDiv() {
document.getElementById("word1").innerHTML = m;
document.getElementById("word2").innerHTML = j;
document.getElementById("word3").innerHTML = k;
document.getElementById("word4").innerHTML = l;
}
setInterval(autoRefreshDiv, 1000);
// geting element name from div
var bake = document.getElementById("word1").innerHTML;
console.log(bake);
//function for creating new element if the word matches
function crElement() {
var element = document.getElementById("arpos").querySelectorAll("div");
var siv = document.getElementById("arpos").querySelector("div");
let siv1 = document.createElement("div");
siv1.textContent(wordfall.random());
element.replaceChild(siv, siv1);
}
let n;
let b;
var i = 0;
function increment() {
i++;
document.getElementById("bron").innerHTML = i;
}
setInterval(increment, 300);
//function for process after submit button is pressed
document.getElementById("submit").onclick = function() {
n = document.getElementById("myInput").value;
b = document.getElementById("word1").value;
if (b == n) {
crElement();
}
};