Std XI I.T || Skill Set 3 – JavaScript || SOP3


SOP3: Create JavaScript program for the following using appropriate variables, JavaScript inbuilt string functions and control structures.

  •       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>

  •         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>

  •        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

Popular posts from this blog

Std XI I.T || Skill Set 3 – JavaScript || SOP1

Std. XI I.T || Skill Set 2 - HTML5 || SOP 4