CSSL Assignment
Name: Nikhil Chaugule
Roll No: 34
1. Write a JavaScript to display the pathname of the web page using
[Link] object.
<html>
<head>
<title>display pathname</title>
</head>
<body>
<script type="text/javascript">
function display(){
var currentpath = [Link];
[Link]("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 = [Link];
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);
[Link](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 = [Link](/[aeiou]/gi).length;
return count;
}
const string = prompt('Enter a string: ');
const result = countVowel(string);
[Link](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++)
{
}