-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
96 lines (54 loc) · 1.58 KB
/
app.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
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
document.addEventListener("DOMContentLoaded", function(event) {
console.log("DOM loaded launching functions");
let button = document.getElementById("button");
let container = document.querySelector(".container");
let x = document.getElementById("input").value;
let arraylength = 10;
let title = document.createElement('H1');
let havebeenused = 0;
button.onclick = function() {
let x = document.getElementById("input").value;
let r = document.querySelector('input[name="wherewestart"]:checked').value;
console.log("valeur de l'input", x);
console.log("valeur de la radio", r);
console.log("container", container);
cleanthedom();
createarray(x, r);
}
function cleanthedom() {
if (havebeenused >= 1) {
console.log("removing the content");
let lol = container.title.innerHTML ="";
console.log("title", title);
console.log("lol", lol);
return lol;
} else {
console.log("going out");
return false;
}
}
function createarray(x, r) {
let array = [];
let i = 0;
let v = 0;
console.log("r dans la function", r);
if (r == 1) {
v = 1;
console.log("i", i);
} else {
v = 0;
console.log("i", i);
}
container.appendChild(title)
while (i < x) {
array.push([i+v]);
title.innerHTML = array;
i++;
}
havebeenused++;
console.log("tableau", array);
console.log("valeur de l'input", x);
return;
}
});
let container = document.querySelector(".container");