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

CSS Pract-3

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

CSS Pract-3

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

Practical-3:- Develop JavaScript to implements Array functionalities

Code-1:

<html>

<body>

<script>

document.write("Array Functionalities :"+ "<br/>");

var a=[91,110,89,56,84];

document.write("1. The Length of array is : " + a.length);

document.write("</br>");

document.write("2. Displaying Array Elements:");

for (i=0; i<a.length; i++){

document.write(a[i] + "<br/>");

document.write("3. The elements is Added in array:" +"<br>");

a[a.length]=90;

a[a.length]=150;

document.write("Display Array Elements:");

document.write("</br>");

for (i=0; i<a.length; i++){

document.write(a[i] + "<br/>");

a.sort();

document.write("4. Display Array Elements After Sorting:");


document.write("</br>");

for (i=0; i<a.length; i++){

document.write(a[i] + "<br/>");

var num=a.shift();

document.write("Removed element is : " + num + "<br>");

document.write("5. Dispaly Array element After shift function is : " +

"<br>"); for (i=0;i<a.length;i++){

document.write(a[i] + "<br>");

var length = a.push(100);

document.write("6. Dispaly Array element After push function is: " + a );

document.write("</br>");

var element = a.pop();

document.write("7. Dispaly Array element After pop function is: " + a );

document.write("</br>");

var arr = a.reverse();

document.write("8. Dispaly Array element After Reverse function is: " + arr );

</script>

</body>

</html>

Output:-
Code-2:

<html>

<body>

<script>

var i;

var emp = new Array();

emp[0] = "Lily";

emp[1] = "Vaishu";

emp[2] = "Harshu";

for (i=0;i<emp.length;i++){

document.write(emp[i] + "<br>");

</script>

</body>

</html>

Output:-
Code-3:

<html>

<body>

<script>

function func()

var s = 'It';

var value = s.concat(' is',' a',' great',' day.');

document.write("String after concat: "+value);

var str = new String( "Computer Engineering.");

document.writeln("<br />String after str.charAt(4) is: " + str.charAt(4));

document.writeln("<br />String after str.charAt(5) is: " + str.charAt(5));

var index = str.indexOf( "Knowledge" );

document.write("<br />String after indexOf : " + index );

var splitted = str.split(" ", 2);

document.write( "<br />String after split : " + splitted );

document.write("<br />String after substr : " + str.substr(0,21));

document.write("<br />String after substring: " + str.substring(0, 20));

document.write("<br />String after toLowerCase: "+str.toLowerCase( ));

document.write("<br />String after toUpperCase: "+str.toUpperCase( ));

func();

</script> </html>
Output:

You might also like