11th Class . IT(Information Technology) Skill Set 3 - Javascript. Sop-3
STD: 11th. Subject: IT(Information Technology)
Client Side Scripting (JavaScript)
Skill Set 3 - Javascript
SOP 3 : Create Javascript Program For The Following Using Appropriate Variables, Javascript Inbuilt String Functions And Control Structures.
To accept string and calculate its length.
To accept string and display it into lowercase and uppercase.
To check whether the length of string is 4 or greater.
Solution :
To accept string and calculate its length.
<!DOCTYPE html>
<html>
<head>
<title>sop3</title>
</head>
<body>
<h1> To accept string and calculate its length </h1>
<script language=javascript>
var n
n=prompt("Enter any text")
s=n.length
document.write("Length of the string is "+s)
</script>
</body>
</html>
Output:
To accept string and display it into lowercase and uppercase.
<!DOCTYPE html>
<html>
<head>
<title>sop3</title>
</head>
<body>
<h1> To accept string and display it into lowercase and uppercase </h1>
<script language=javascript>
var n
n=prompt("Enter any text")
s1=n.toUpperCase()
s2=n.toLowerCase()
document.write("Uppercase of the string is "+s1 + "<br>")
document.write("Lowercase of the string is "+s2)
</script>
</body>
</html>
Output:
To check whether the length of string is 4 or greater.
<!DOCTYPE html>
<html>
<head>
<title>sop3</title>
</head>
<body>
<h1> To check whether the length of string is 4 or greater </h1>
<script language=javascript>
var n
n=prompt("Enter any text")
if(n.length>=4)
document.write("Length of the string is greater than or equal to 4")
else
document.write("Length of the string is less than 4")
</script>
</body>
</html>
Comments
Post a Comment