forked from vJechsmayr/JavaScriptAlgorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
39 lines (31 loc) · 883 Bytes
/
Copy pathindex.html
File metadata and controls
39 lines (31 loc) · 883 Bytes
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
<!DOCTYPE html>
<html>
<head>
<title>Javascrip Algorithm</title>
<script type="text/javascript" src="./fibonacci.js"></script>
</head>
<body>
<h1>Go to console</h1>
<br>
<h2>Type fibonacci(n), where n is the number of elements you want in series</h2>
<br>
<br>
<br>
<h3>OR just playaround with number</h3>
<input id="number" type="number" placeholder="input number" onchange="displayFibs()">
<div id="fib_content"></div>
</body>
<script type="text/javascript">
function displayFibs () {
const input = document.getElementById("number")
const fibs = fibonacci(parseInt(input.value))
const content = document.getElementById("fib_content")
content.innerHTML = ""
for (i=0;i<fibs.length;i++) {
let div = document.createElement('span');
div.innerHTML = "<span>" + fibs[i] + ", </span>"
content.appendChild(div);
}
}
</script>
</html>