Professional Documents
Culture Documents
Var A 0, B 1, C Document - Write ("Fibonacci") While (B ") C A+b A B B C )
Var A 0, B 1, C Document - Write ("Fibonacci") While (B ") C A+b A B B C )
<html>
<body>
<script type="text/javascript">
var a=0,b=1,c;
document.write("Fibonacci");
while (b<=20)
{
document.write(c);
document.write("<br/>");
c=a+b;
a=b;
b=c;
}
</script>
</body>
</html>
Q2
(i)<html>
<body>
<script type="text/javascript">
else{
document.write("<b>Does not qualify for driving</b>");
}
</script>
(ii)<html>
<body>
<button onclick="myFunction()">Try it</button>
<br/>
<br/>Enter first number:
<input type="text" id="txt1" name="text1">Enter second number:
<input type="text" id="txt2" name="text2">
<script>
function myFunction() {
var y = document.getElementById("txt1").value;
var z = document.getElementById("txt2").value;
var x = y + z;
var d= y-z;
document.write(x);
document.write(d);
}
</script>
</body>
</html>
Q3
<html>
<body>
<script type="text/javascript">
var grade='A';
document.write("Entering switch block<br />");
switch (grade)
{
case 'A': document.write("Good job<br />");
break;
break;
</script>
Q4
<html>
<head>
<script type="text/javascript">
function over()
{
document.write("Mouse Over");
}
function out()
{
document.write("Mouse Out");
}
</script>
</head>
<body>
<p> Bring your mouse inside the division to see the result:</p>
<div onmouse="over()"
onmouse="out()" >
<h2> This is inside the division </h2>
</div>
</body>
</html>
Q5
<html>
<head>
<script type="text/javascript">
function getvalue()
{
var retval=prompt("Enter your name:","your name here");
document.write("you have entered"+retval);
}
</script>
</head>
<body>
<p> click the following button to see the result:</p>
<form>
<input type="button" value="click me" onclick="getvalue();"/>
</form>
</body>
</html>
Q6
<html>
<head>
<script type="text/javascript">
var teststring = 'abcdedcba';
function IsPalindromeIteration(str){
var len = str.length, i=0, result = true;
if (len <= 1) return true;
while(i != len - i - 1){
var start = str.charAt(i),
end = str.charAt(len - i - 1);
if (start != end){
return false;
}
i++;
}
return result;
}