JavaScript Important Questions for NEB Board Exam


JavaScript - NEB Board Exam Important Questions


Here are some of the most probable questions of Web Technology II (JavaScript) for upcoming NEB Board Exam :


1. Simple Event Handling

<html>

<head><title>Event Handle</title>

<script type="text/javascript">

function sayHello()

{

              alert("Hello World");

}

</script></head>

<body>

<input type="button" onclick="return sayHello()" value="Click me" >

</body>

</html>

 

2. Factorial in JavaScript

<html><head><title>Factorial</title>

<script type="text/javascript">

function fact()

{

var n=prompt("Enter number");

var fact=1;

for(var i=1;i<=n;i++)

{

              fact=fact*i;

}

 

document.write("Factorial is:"+fact);

}

</script>

</head>

<body>

 

<input type="button" onclick="fact()" value="FACTORIAL" >

</body></html>

 

3. FORM Validation in JavaScript

<html>

<head><title>MY FIRST FORM</title>

<script type="text/javascript">

function validate()

{

var name=document.form.name.value;

var password=document.form.password.value;

if(name=="")

{

              alert("Enter valid name");

              return false;

}

else if(password.length<6)

{

              alert("Enter larger password");

              return false;

}

}

</script>

</head>

 

<body>

<form name="form" action="" onsubmit="validate()" method="post" >

Name:<input type="text" name="name"><br><br>

Password:<input type="password" name="password"><br><br>

 

<input type="submit" value="Submit" >

</form></body></html>

 

 4. Multiplication Table

<html><body>

<p>multiplication table</p>

<script type="text/javascript">

var n=prompt("Enter any nummber:");

var i;

 

for(i=1;i<=10;i++)

{

              document.write(n+"x"+i+"="+n*i);

              document.write("<br>");

}

</script>

</body>

</html>

   

  

5. Check either number is Palidrome or not

<html>

<head><title>palindrome</title></head>

<body>

<script type="text/javascript">

var n=parseInt(prompt("Enter any number:"));

var rem,copy,rev=0;

copy=n;

 

while(n!=0)

{

              rem=n%10;

              rev=rev*10+rem;

              n=parseInt(n/10);

}

document.write("Reverse is:"+rev);

document.write("<br>");

if(rev==copy)

{

              document.write("It is palindrome");

}

else

{

              document.write("It is not palindrome");

}

 

</script></body></html>

  

 

6. Star Pattern

<html>

<body>

<script type="text/javascript">

var n=prompt("Enter number of rows");

var i,j;

 

for(i=n;i>=1;i--)

{

              for(j=1;j<=i;j++)

              {

                            document.write("*");

              }

document.write("<br>");

}

</script></body></html>

 

 

7. Sum of two numbers

<html>

<head><title>ADD TWO NUMBERS</title></head>

<body>

<script type="text/javascript">

var a=parseInt(prompt("Enter first number:"));

var b=parseInt(prompt("Enter second number:"));

var c=a+b;

 

document.write("Sum is"  +c);

</script></body></html>




⚠️ For C Programming important questions :