0% found this document useful (0 votes)
19 views5 pages

HTML Lang Charset Content Name Content

The document contains code to implement string manipulation functions in JavaScript. It defines a sample string and buttons to call functions that take the string as input and output the uppercase, lowercase, concatenated with "Hello", length, and character indexes to a result element. The functions manipulate the string and display the output below the buttons.

Uploaded by

Isha Rangari
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)
19 views5 pages

HTML Lang Charset Content Name Content

The document contains code to implement string manipulation functions in JavaScript. It defines a sample string and buttons to call functions that take the string as input and output the uppercase, lowercase, concatenated with "Hello", length, and character indexes to a result element. The functions manipulate the string and display the output below the buttons.

Uploaded by

Isha Rangari
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/ 5

Practical No.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>Practical No. 05</title>
</head>
<body>
<center>
<h1>CSS : Practical No 5</h1>
<h2>Develop Javascript To Implement Strings</h2>
<br><br>

<h3 id="fname">Sample String : Shantanu</h3>

<script>
var name =
document.getElementById("fname").textContent.slice(16);

function toUpperCaseString(){
document.getElementById("result").textContent =
"Uppercase : " + name.toUpperCase();
}

function toLowerCaseString(){
document.getElementById("result").textContent =
"Lowercase : " + name.toLowerCase();
}

function concatNewString(){
document.getElementById("result").textContent =
"Concatenation : " + "Hello, ".concat(name);
}

function stringLength(){
document.getElementById("result").textContent =
"Length : " + name.length;
}

function indexOfCharacters(){
var index = 0;
var result = "";

for(index; index < name.length; index++){


result = result + (name[index] + " = " +
name.indexOf(name[index], index) + ", ");
}
document.getElementById("result").textContent =
"Index Of : " + result;
}

</script>
<button onclick="toUpperCaseString()">Uppercase All</button>
<button onclick="toLowerCaseString()">Lowercase All</button>
<button onclick="concatNewString()">Prefix Hello</button>
<button onclick="stringLength()">String Length</button>
<button onclick="indexOfCharacters()">Index of All
Characters</button>

<br><br>
<h2 id="result"></h2>
</center>
</body>
</html>
Output :

After Pressing Uppercase All Button :


After Pressing Lowercase All Button :

After Pressing Prefix Hello Button :


After Pressing String Length Button :

After Pressing Index Of All Characters Button :

You might also like