-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontrol.html
45 lines (45 loc) · 1.45 KB
/
control.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
42
43
44
45
<!DOCTYPE html>
<html>
<body>
<input type="text" id="box"><br>
<button type="button" onclick="check()">Check</button><button type="button" onclick="fibo()">Fibo</button><br>
<textarea id="area" cols="25" rows="5"></textarea>
<script>
function check(){
var n = document.getElementById("box").value;
n=parseInt(n);
str="";
try{
if(n<10){
throw "Number is less than 10";
}
else if(n>=10 && n<=100){
throw "Number is between in 10 and 100";
}
else{
throw "Number is greater tha 100";
}
}
catch(err){
document.getElementById("area").innerHTML=err;
}
finally{
document.getElementById("area").innerHTML+=" Finally";
}
}
function fibo(){
var n = document.getElementById("box").value;
n=parseInt(n);
str="0";
var a1=0,a2=1,i,res=0;
for(i=0;i<n-1;i++){
res=a1+a2;
a1=a2;
a2=res;
str+=", "+res;
}
document.getElementById("area").innerHTML=str;
}
</script>
</body>
</html>