-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSpindler_ES6_Functions.html
41 lines (34 loc) · 1000 Bytes
/
Spindler_ES6_Functions.html
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
<!DOCTYPE html>
<html>
<head>
<title>Lab #9</title>
</head>
<body>
<div id="todo"></div>
<script>
let toDoListToPass = ['todo1', 'todo2', 'todo3', 'todo4', 'todo5']
let headerToPass = "To-Do: "
const addToDoHeader = (header) => {
const toDoElement = document.getElementById('todo');
if (!toDoElement)
return;
toDoElement.innerHTML = '<h1>' + header + '</h1>';
}
const generateToDoListHTML = (toDoList) => {
let toDoListHTML = '';
for (let i = 0; i < toDoList.length; i++)
toDoListHTML += '<p>' + toDoList[i] + '</p>';
return toDoListHTML;
}
const addToDoList = (toDoList) => {
const toDoElement = document.getElementById('todo');
if (!toDoElement)
return;
const toDoListHTML = generateToDoListHTML(toDoList);
toDoElement.innerHTML += toDoListHTML;
}
addToDoHeader(headerToPass);
addToDoList(toDoListToPass);
</script>
</body>
</html>