Professional Documents
Culture Documents
Output:
Output:
<html>
<body>
<script>
</script>
</body>
</html>
Output:
Q 4) Write JavaScript Program to Check if a number is
Positive, Negative, or Zero.
Program:
<!DOCTYPE html>
<html>
<body>
<script>
if (number > 0)
else if (number == 0)
else
</script>
</body>
</html>
Output:
<html>
<body>
<script>
var i = 1;
var count = 0;
if(num % i == 0)
count++;
if(count == 2)
else
</script>
</body>
</html>
Output:
<head>
<title>Multiplication Table</title>
</head>
<body>
<script>
rows = 10;
cols = 10;
createTable(rows, cols);
var j=1;
for(i=1;i<=rows;i++)
while(j<=cols)
j = j+1;
j = 1;
}
output = output + "</table>";
document.write(output);
</script>
</body>
</html>
Output:
Q 7) Write a JavaScript function that reverse a number.
Program:
<!doctype html>
<html>
<head>
<title>
Reverse Number
</title>
<script>
function palin()
var a,n,b,temp=0;
n=Number(document.getElementById("n_input").value);
b=n;
while(n>0)
a=n%10;
n=parseInt(n/10);
temp=temp*10+a;
alert(temp);
</script>
</head>
<body>
<button onclick="palin()">
Check
</button>
</body>
</html>
Output:
Q 8) Write a JavaScript function that checks whether a
passed string is palindrome or not?
Program:
<!DOCTYPE html>
<html>
<body>
<script>
let x = str[i] ;
let y = str[j-i];
if( x != y)
return false;
}
return true;
else
is_palindrome(test);
</script>
</body>
</html>
Output:
Q 9) Write a JavaScript function which will take an
array of numbers stored and find the second lowest and
second greatest numbers, respectively
Program:
<!DOCTYPE html>
<html>
<head>
<title>
Find the second lowest and second greatest numbers from an array
</title>
</head>
<body>
<script>
function Second_Greatest_Lowest(arr_num)
arr_num.sort(function(x,y)
return x-y;
});
uniqa.push(arr_num[j]);
result.push(uniqa[1],uniqa[uniqa.length-2]);
return result.join(',');
console.log(Second_Greatest_Lowest([1,2,3,4]));
</script>
</body>
</html>
Output:
<html>
<head>
<title>
</title>
</head>
<body>
<script>
var arr2=[];
var min=arr1[0];
var pos;
var max=arr1[0];
if (max<arr1[i]) max=arr1[i];
{
for (var j=0;j<arr1.length;j++)
if (arr1[j]!="x")
if (min>arr1[j])
min=arr1[j];
pos=j;
arr2[i]=min;
arr1[pos]="x";
min=max;
console.log(arr2);
</script>
</body>
</html>
Output: