Javascript Complete
Javascript Complete
<body> <body>
<script type = "text/javascript"> <Script type ="text/JavaScript">
var l = prompt("pls enter no for a","l="); var a = prompt("a=");
var w = prompt("pls enter no for var b = prompt("b=");
a","w="); if(a<b)
a=l*w; {
document.write(alert(a)); document.write("A is smallest");
</script> }
</head> </Script>
</body> </body>
</html> </head>
</html>
Q5. ConfirmBox
Ans. Q7. Conditional (Ternary) Operator
<html> Ans.
<head> <html>
<body> <head>
<Script type ="text/JavaScript"> <body>
var a = confirm ("Are You Happy"); <Script type ="text/JavaScript">
if (a ==1) var a = prompt("a=");
{ var b = prompt("b=");
document.write("As You are happy"); (a<b) ? document.write("A is
} smallest"):document.write("B is
else smallest");
{ </Script>
document.write("not happy "); </body>
} </head>
</Script> </html>
</body>
</head> Q8. week of day (using else if)
</html> Ans.
<html>
If and if else <head>
<body>
Q6. if structure
<Script type ="text/JavaScript">
Ans.
var no = prompt("no=");
<html>
if (no == 1)
<head>
3
} document.write("Sunday");
</script> break;
</head> default:
</body> document.write("Invilid no");
</html> }
</Script>
Switch Case </body>
</head>
Q14. week of day (using Switch Case
</html>
structure)
Ans.
<html> For Loop
<head> Q15. Draw a Programme that print 1 to
<body> 10 no. ?
<Script type ="text/JavaScript"> Ans.
var no = prompt("no="); <html>
var no = parseInt(no) <head>
switch (no) <body>
{ <script type = "text/javascript">
case 1: for(i=1;i<=10;i++)
document.write("Monday"); {
break; document.write(i);
case 2: }
document.write("Tuesday"); </script>
break; </head>
case 3: </body>
document.write("Wedensday"); </html>
break;
case 4: Q16. Draw a Programme that print 10
document.write("Thirsday"); to 1 no. ?
break; Ans.<html>
case 5: <head>
document.write("Friday"); <body>
break; <script type = "text/javascript">
case 6: //var a = prompt("pls enter no for
document.write("Saturday"); a","a=");
break; for(i=10;i>=1;i--)
case 7: {
6
Q18. Sum of 1 to 10 no? (for loop) Q20. Draw a Program that accept Base
Ans. and Power and print its value?
<html> Ans.
<head> <html>
<body> <head>
<Script type ="text/JavaScript"> <body>
sum = 0; <script type = "text/javascript">
for (i =1; i<= 10; i++) var b = prompt("pls enter no for b");
{ var p = prompt("pls enter no for p");
7
</body> </script></head>
</html> <body>
<script type ="text/javascript">
Function add (3);
Q27. Function add (5);
Ans. </script>
<html> </body>
<head> </html>
<script type = "text/javascript">
Q29. Draw a Programme that accept
function showcube (x)
character and print vowel or consonent
{
? (not run)
document.write("The cube of: "
Ans.
+x+ "is" +x*x*x+ "<br>")
<html>
} <head>
</script></head> <body>
<body> <script type = "text/javascript">
<script type ="text/javascript"> var let = prompt("your letter");
showcube (3); if(let == 'a' ||
showcube (5); let =='e'||
showcube (7); let=='i'||
</script> let='o'||
</body> let='u')
{
</html>
alert ("Your letter is Vowel");
}
Q28. Add two no with function?
else
Ans.
{
<html> alert ("Your letter is cons");
<head> }
<script type = "text/javascript"> //document.write("<br>",num*i);
function add (a) </script>
{ </head>
document.write("The cube of: " +a+ </body>
"is" +a+a+ "<br>") </html>
} <html>
10
<head>
Q Output your name
ans.
<script type = "text/javascript">
var name = prompt("pls enter character
your name","text type here");
</script>
</head>
<body>
<script type = "text/javascript">
document.write("<h2>Your name is
"+name+"</h2>");
</script>
</body>
</html>