assignament no 2
assignament no 2
1)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Factorial Calculator</title>
</head>
<body>
<h2>Factorial Calculator</h2>
<p id="result"></p>
<script>
function factorial(n) {
if (n === 0 || n === 1) {
return 1;
} else {
let result = 1;
result *= i;
return result;
function calculateFactorial() {
} else {
</script>
</body>
</html>
Quistion no. 2)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Palindrome Checker</title>
</head>
<body>
<h2>Palindrome Checker</h2>
<p id="result"></p>
<script>
function isPalindrome(input) {
function checkPalindrome() {
} else {
if (isPalindromeResult) {
} else {
</script>
</body>
</html>
Question 3)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
<p id="result"></p>
<script>
function sumOfDigits(number) {
if (numString.length !== 4) {
let sum = 0;
sum += parseInt(numString[i]);
return sum;
function calculateSum() {
} else {
</script>
</body>
</html>
Question no 4)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Fibonacci Series</title>
</head>
<body>
<h2>Fibonacci Series</h2>
<p>Enter the value of 'n' to find the nth term of Fibonacci Series:</p>
<p id="fibonacciSeriesResult"></p>
<p id="nthTermResult"></p>
<script>
function printFibonacciSeries() {
let a = 0, b = 1, nextTerm;
nextTerm = a + b;
a = b;
b = nextTerm;
nextTerm = a + b;
document.getElementById('fibonacciSeriesResult').textContent = series;
function findNthTerm(n) {
let a = 0, b = 1, nextTerm;
nextTerm = a + b;
a = b;
b = nextTerm;
return b;
function findAndDisplayNthTerm() {
} else {
</script>
</body>
</html>
Question no 5)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Array Analysis</title>
</head>
<body>
<h2>Array Analysis</h2>
<p id="arrayResult"></p>
<p id="evenResult"></p>
<p id="oddResult"></p>
<p id="primeResult"></p>
<script>
function isPrime(num) {
if (num <= 1) {
return false;
if (num % i === 0) {
return false;
return true;
function countEvenOddPrimeNumbers(arr) {
let evenCount = 0;
let oddCount = 0;
let primeCount = 0;
if (arr[i] % 2 === 0) {
evenCount++;
} else {
oddCount++;
if (isPrime(arr[i])) {
primeCount++;
function processArray() {
</script>
</body>
</html>
Question no 6)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Text Analyzer</title>
</head>
<body>
<h2>Text Analyzer</h2>
<p id="vowelResult"></p>
<p id="consonantResult"></p>
<p id="wordResult"></p>
<script>
function countVowelsAndConsonants(text) {
let vowelCount = 0;
let consonantCount = 0;
vowelCount++;
} else if (char.match(/[a-zA-Z]/)) {
consonantCount++;
function countWords(text) {
return words.length;
function analyzeText() {
</script>
</body>
</html>