PROGRAM FOR STRING MANIPULATION IN JAVASCRIPT

 strmanipulation.html

<HTML>

<BODY>

<script language="Javascript">

 var a=prompt("Enter any string for manipulation","mapple");

document.write("given string is    "+a);

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

document.write("Length of the given string is    "+a.length);

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

document.write("Given string displayed in lowercase    "+a.toLowerCase( ));

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

document.write("Given string displayed in uppercase     "+a.toUpperCase( ));

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

document.write("Extracts from the given string(0,2):         "+a.substring(0,2));

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

var r=prompt("Enter any character to replace  ");

var t=prompt("Enter any character to replace with  ");

document.write("String Replace("+r+","+t+") is        "+a.replace(r,t));

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

var b=prompt("Enter any string to combine      ","street");

document.write("String concatenation ("+a+","+b+") is      "+a.concat(b));

  </script>

</BODY>

</HTML>

OUTPUT:



No comments:

Post a Comment