-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunction.js
57 lines (37 loc) · 1.37 KB
/
function.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
// 'use strict'
// function randomNambur(multiplyBy) {
// return Math.floor(Math.random() * multiplyBy);
// }
// function popuLateUnorderList(elementId,input) {
// const list = document.getElementById(elementId);
// const li = document.createElement('li');
// li.innerHTML = input;
// list.appendChild(li);
// }
// popuLateUnorderList("liste","hallo");
//schreib die function sodass ein array belibiger lange
//ubergeben werden kann. fuer jedes element des array soll ein neues <li>
//element erzeugt und liste hinzugefugt werden
// function generateList() {
// const newList = document.createElement('ul');
// for (let i = 0; i<'lord of the ring'.length; i++) {
// const book = 'lord of the ring'[i];
// newList.innerHTML += `<li>${book}</li>`;
// }
// return newList;
// }
// document.body.append(generateList());
function makeUL(array) {
// Create the list element:
var list = document.createElement('ul');
for (var i = 0; i < array.length; i++) {
// Create the list item:
var item = document.createElement('li');
// Set its contents:
item.appendChild(document.createTextNode(array[i]));
// Add it to the list:
list.appendChild(item);
}
// Finally, return the constructed list:
return list;
}