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

rn4 js5

The document implements various string methods in JavaScript like concat, toUpperCase, toLowerCase, replace, substr, substring, charCodeAt, match, search, lastIndexOf, toString and valueOf. It takes an input string and applies each method to demonstrate how it works, outputting the results to the page.

Uploaded by

newsneha775
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)
27 views

rn4 js5

The document implements various string methods in JavaScript like concat, toUpperCase, toLowerCase, replace, substr, substring, charCodeAt, match, search, lastIndexOf, toString and valueOf. It takes an input string and applies each method to demonstrate how it works, outputting the results to the page.

Uploaded by

newsneha775
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/ 5

Practical 5 : Develop Javascript to implement String functionalities.

Code:

<html >

<head>

<title>Experiment 5</title>

<style>

.code-block {

background: #F700b5;

padding: 8px;

font-family: Ariel;

font-size:30PX;

margin: 15px;

border-radius:10px;

body{

background-color: orange;

.container

width:50%;

border:1px solid black;

</style>

</head>

<body>

<h2 style="text-align: center;font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe


UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;"> Experiment
No.5 :String methods</h2>

<center><div class="container">
<div class="code-block">

<script>

var str = "JavaScript";

document.write("<strong>Input String is: </strong>" + str);

</script>

</div>

<div class="code-block">

<script>

var newstr = str.concat(" is "+"Good "+"Programming Language");

document.write("<strong>Concatinated String is: </strong>" + newstr);

</script>

</div>

<div class="code-block">

<script>

document.write("<strong>Uppercased String is: </strong>" + str.toUpperCase());

</script>

</div>

<div class="code-block">

<script>

document.write("<strong>Uppercased String is: </strong>" + str.toLowerCase());

</script>

</div>

<div class="code-block">

<script>

document.write("<strong>Uppercased String is: </strong>" + newstr.replace("Good","nice"));

</script>

</div>

<div class="code-block">

<script>

var str1=newstr.substr(0,18)

document.write("<strong>substr(0,18) String is: </strong>" + str1);


</script>

</div>

<div class="code-block">

<script>

var str2=newstr.substring(14,30)

document.write("<strong>substring(14,30) String is: </strong>" + str2);

</script>

</div>

<div class="code-block">

<script>

var s1="Javascript is Language";

var str2=s1.charCodeAt(4)

document.write("<strong>CharCodeAt 4: </strong>" + str2);

</script>

</div>

<div class="code-block">

<script>

var s1="Javascript is Language";

var str2=s1.match(/is/g)

document.write("<strong>match: </strong>" + str2);

</script>

</div>

<div class="code-block">

<script>

var s1="Javascript is Language";

var str2=s1.search("Language")

document.write("<strong>Search : </strong>" + str2);

</script>
</div>

<div class="code-block">

<script>

var s1="Javascript is Language";

var str2=s1.replace("Language","CSS")

document.write("<strong>Replace : </strong>" + str2);

</script>

</div>

<div class="code-block">

<script>

var s1="Javascript is Language";

var str2=s1.lastIndexOf("Language")

document.write("<strong>lastIndexOf : </strong>" + str2);

</script>

</div>

<div class="code-block">

<script>

var s1=42;

var str2=s1.toString();

document.write("<strong>toString : </strong>" + str2);

</script>

</div>

<div class="code-block">

<script>

var s1="Java";

var str2=s1.valueOf();

document.write("<strong>valueOf : </strong>" + str2);

</script>
</div

<div class="code-block">

<script>

var s1="java";

var str2=s1.charAt(2);

document.write("<strong>toString : </strong>" + str2);

</script>

</div>

</div></center>

</body>

</html>

Output:-

You might also like