Tuesday, December 1, 2015

String and Math Functions in JavaScript

This sample program will show you basic string and math built in functions in JavaScript that is very handy to use in our programming assignments and projects. I hope you will find our sample program useful.

If you  have some questions please send me an email at jake.r.pomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.
 

Program Listing

<html>
    <head>
        <title> String and Math Functions</title>
        <script language = "Javascript">


        function dblenum(i)
        {
            dblnumber = numb * numb;
            return(dblnumber);
        }


        var name = prompt ("Enter your name:","");
        var numb = parseInt (prompt ("Enter any number:"," "));
        var deit = prompt ("Enter the date:","");
        var dt = new Date(deit);
       
        var sqre = dblenum (numb);

        document.write ("<center>");
        document.write ("Lowercase:     ",name.toLowerCase(),"<br>");
        document.write ("Uppercase:     ",name.toUpperCase(),"<br>");
        document.write ("Length:        ",name.length,"<br>");
        document.write ("Double:        ",sqre,"<br>");
        document.write ("Square Root:   ",Math.sqrt(numb),"<br>");
        document.write ("Round Off:     ",Math.round(numb),"<br>");
        document.write ("Date: Day   -  ",(dt.getDay()+1),"<br>");
        document.write ("      Month -  ",(dt.getMonth()+1),"<br>");
        document.write ("      Date  -  ",dt.getDate(),"<br>");
        document.write ("      Year  -  ",dt.getYear(),"<br>");
       
        </script>
    </head>

<body bgcolor = "green" text = "white">

</body>
</html>
 



No comments:

Post a Comment