0% found this document useful (0 votes)
11 views

cssl Assignment

The document contains a CSSL assignment by Nikhil Chaugule, Roll No: 34, which includes five JavaScript tasks. These tasks involve displaying the webpage pathname, initializing and displaying an array of fruits, checking if a string is a palindrome, counting vowels in a string, and generating a Fibonacci series up to a user-defined limit. Each task is accompanied by HTML and JavaScript code snippets demonstrating the required functionality.

Uploaded by

mayurve109
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

cssl Assignment

The document contains a CSSL assignment by Nikhil Chaugule, Roll No: 34, which includes five JavaScript tasks. These tasks involve displaying the webpage pathname, initializing and displaying an array of fruits, checking if a string is a palindrome, counting vowels in a string, and generating a Fibonacci series up to a user-defined limit. Each task is accompanied by HTML and JavaScript code snippets demonstrating the required functionality.

Uploaded by

mayurve109
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

CSSL Assignment

Name: Nikhil Chaugule


Roll No: 34

1. Write a JavaScript to display the pathname of the web page using


window.location object.

<html>
<head>
<title>display pathname</title>
</head>
<body>
<script type="text/javascript">
function display(){
var currentpath = window.location.pathname;
document.write("pathname = "+currentpath);
};
</script>
<form name="myform">
<input type="button" value="get pathname" onclick="display()">
</form>
</body>
</html>

2. Write a JavaScript that initializes an array called “Fruits” with names of five
fruits. The script then displays the array in a message box.

<html>
<head>
<title>Array</title>
</head>
<body>
<script type="text/javascript">
var Fruits = new Array(5);
Fruits[0]="apple";
Fruits[1]="banana";
Fruits[2]="mango";
Fruits[3]="pair";
Fruits[4]="papaya";
alert("array element="+Fruits);
</script>
</body>
</html>

3. Write a JavaScript function that checks whether a passed string is palindrome or


not.

<!DOCTYPE html>
<html>
<head>
<title>program to check if the string is palindrome or not</title>
</head>
<body>
<script type="text/javascript">
function checkPalindrome(string)
{
const len = string.length;
for (var i = 0; i < len / 2; i++)
{
if (string[i] !== string[len - 1 - i])
{
return 'It is not a palindrome';
}
}
return 'It is a palindrome';
}
const string = prompt('Enter a string: ');
// call the function
const value = checkPalindrome(string);
document.write(value);
</script>
</body>
</html>

4. Write a JavaScript function to count the number of vowels in a given string.

<!DOCTYPE html>
<html>
<head>

<title>count number of vowels in string</title>


</head>
<body>
<script type="text/javascript">
function countVowel(str) {
const count = str.match(/[aeiou]/gi).length;
return count;
}
const string = prompt('Enter a string: ');
const result = countVowel(string);
document.write(result);
</script>
</body>
</html>

5. Write a javascript function to generate Fibonacci series till user defined limit.

<html>
<head>
<title>Fibonacci series </title>
</head>
<body>
<script type=”text/javascript”>
var n1=0,n2=1,i;
var num= parseInt(prompt(“enter limit for generate fibonacci series ”));
for(i=0;i<=num;i++)
{
}

You might also like