[go: up one dir, main page]

0% found this document useful (0 votes)
100 views10 pages

Practical No 5

Practical 5 of CSS

Uploaded by

huzaifasajid73
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)
100 views10 pages

Practical No 5

Practical 5 of CSS

Uploaded by

huzaifasajid73
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/ 10

Practical No.

AIM: Develop JavaScript to implement strings.

<html>

<body>

<script>

var txt = "Hello JavaScript World!";

document.write("<p>" + txt.length + "</p>");

var txt="Amar and Akbar";

document.write("<p>" + txt.length + "</p>");

</script>

</body>

</html>

<html>

<head>

<title> scope</title>

<script>

var str1 = new String("Paras ");

var str2 = new String("V ");

var str3= new String("Lad");

var str4 = str1+str3;

var str5 = str2.concat(str3);

var str6 = str1.concat(str2, str3);

document.write("str4 :" + str4);

document.write("<br>str5 : " + str5); document.write("<br>str6: " + str6);

</script>
</head>

<body>

</body>

</html>

<html>

<head>

<title>JavaScript String charAt() Method</title>

</head>

<body>

<script type="text/javascript">

var str = new String("This is string");

document.writeln("str.charAt(0) is:" + str.charAt(0));

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

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

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

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

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

</script>

</body>

</html>
<html>

<body>

<script>

var str="JavaScript is a scripting language.";

document.writeln(str.search("scripting"));

</script>

</body>

</html>

<html>

<body>

<script>

var s1="JavaScript is a scripting language";

var n=s1.indexOf("a");

document.writeln(n+"<br>");

document.writeln(s1.search("scripting"));

var m=s1.lastIndexOf("a");

document.writeln("<br>"+m);

</script>

</body>

</html>
<html>

<head>

<title> scope</title>

<script>

function init()

var str = "how are you?";

var n1=str.search("o");

document.write(" 'o' found at location "+ n1);

var n2=str.indexOf("u");

document.write("<br>'u' found at location " + n2);

var n3=str.search('are');

document.write("<br>'are' found at location " + n3);

var n4 = str.indexOf('you');

document.write("<br>'you' found at location " + n4);

</script>

</head>

<body onload="init()"></body>

</html>
<html>

<head>

<title> scope</title>

<script>

function init()

var str = "How are you?";

var res1 = str.split();

document.write("<br>Result1 = "+ res1);

var res2 = str.split("o");

document.write("<br>Result2 =" + res2);

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

document.write("<br>Result3 =" + res3);

</script>

</head>

<body onload="init()"> </body>

</html>

<html>
<head>

<title> scope</title>

<script>

function init()

var str="JavaScript is a Scripting Language.";

document.write("<br>substr: "+ str.substr(16,9));

document.write("<br>substr: "+ str.substr(16));

document.write("<br>substr: "+str.substring(16,25));

document.write("<br>substr: "+ str.substring(16));

document.write("<br>substr: "+ str.substring(25,16));

</script>

</head>

<body onload="init()">

</body>

</html>

<html>

<head>

<title> scope</title>

<script>

function init()

{
var num1=42;

var num2='82';

var result= num1 + parseInt(num2, 10);

document.write("Addition= "+ result);

</script>

</head>

<body onload="init()">

</body>

</html>

<html>

<head>

</head>

<title> scope</title>

<body onload="init()">

<script>

function init()

var num1 = 23;

var num2 = 80;

var result= num1 + num2.toString();

document.write("Result= "+ result);

</script>

</body>

</html>

<html>
<body>

<script>

var str = "JavaScript";

document.writeln(str.toLowerCase());

document.writeln("<br>"+str.toUpperCase());

</script>

</body>

</html>

<html>

<body>

<script>

var txt="Hello JavaScript World!";

document.write("<p>" + txt.toUpperCase() + "</p>");

document.write("<p>" + txt.toLowerCase() + "</p>");

document.write("<p>" + txt + "</p>");

</script>

</body>

</html>

<html>

<body>

<script>

var x="Javatpoint";
document.writeln(x.charCodeAt(3));

document.write("<br>");

var res = String.fromCharCode(72, 69, 76, 76, 79);

var res1 = String.fromCharCode(73, 70, 77, 77, 80);

document.write(res);

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

</script>

</body>

</html>

<html>

<head>

<title> Scope </title>

</head>

<body>

<script>

var txt = "Hello JavaScript World!";

document.write("<p>" + txt.charCodeAt() + "</p>");

document.write("<p>" + txt.charCodeAt(5) + "</p>");

var res = String.fromCharCode (72, 101, 108, 108, 111);

document.write(res );

</script>

</body>

</html>

You might also like