Here you can find a number of examples on Java Script.Please find the various kinds of examples listed on the right side of this site. If you don't find anything on Java Script then please write to us or leave a commnet. We are pleased to help and find the solution of your problem.
Showing posts with label math. Show all posts
Showing posts with label math. Show all posts
JavaScript: Power Function
pow function:
Returns base to the exponent power, that is, baseexponent .
Calculate x raised to y (xy)
Syntax:
pow(x,y)
x is the base number and y is the exponent to which to raise base.
Description:
Because pow is a static method of Math, you always use it as Math.pow(), rather than as a method of a Math object you created.
Example:
<html>
<head>
<title>Power Function</title>
<script language="javascript">
document.write("calculate 5 <sup> 2 </sup> = " + Math.pow(5,2) + "<br>");
document.write("calcuclate 3 <sup> 5 </sup> = " + Math.pow(3,5) + "<br>");
</script>
</head>
</html>
OUTPUT:
calculate 52 = 25
calcuclate 35 = 243
JavaScript: Min Function
Math.min() Function:
Find the minimum number in the array list.
Syntax:
min(number1,number2,.......numbern)
Description:
Because min is a static method of Math, you always use it as Math.min(), rather than as a method of a Math object you created.
Example
<html>
<head>
<title>MIN Function</title>
<script language="javascript">
document.write("The minimum number is " + Math.min(5,8) + " from(5,8)
");
document.write("The minimum number is " + Math.min(-2,-9) + " from(-2,-9)
");
document.write("The minimum number is " + Math.min(7.25,7.30) + " from(7.25,7.30)");
</script>
</head>
</html>
OUTPUT:
The minimum number is 5 from(5,8)
The minimum number is -9 from(-2,-9)
The minimum number is 7.25 from(7.25,7.30)
Labels:
example,
function,
functions,
in,
javascript,
javascriptexample,
math,
min,
minfunction,
on
JavaScript: MAX Function
Math.max() Function:
Find the maximum number in the arraylist.
Syntax:
max(number,numner.........,number)
Description:
Because max is a static method of Math, you always use it as Math.max(), rather than as a method of a Math object you created.
Example:
<html>
<head>
<title>Math.max() Function</title>
<script language="javascript">
document.write("The maximum number is " + Math.max(5,8,10) + " from(5,8,10)
");
document.write("The maximum number is " + Math.max(-4,-7) + " from(-4,-7)
");
</script>
</head>
</html>
OUT PUT
The maximum number is 10 from(5,8,10)
The maximum number is -4 from(-4,-7)
Labels:
find,
function,
functions,
javascript,
javascriptexample,
math,
max,
number
JavaScript: isNaN Function
isNaN Function :-
Evaluates an argument to determine if it is not a number.
Syntax :-
isNaN(value)
value = The value you want to evaluate.
Description :-
isNaN is a top-level function and is not associated with any object.
On platforms that support NaN, the parseFloat and parseInt functions return NaN when they evaluate a value that is not a number. isNaN returns true if passed NaN, and false otherwise.
Example:
<html>
<head>
<title>isNaN Fnction</title>
<script language="javascript">
function check()
{
var phone=f1.phone.value;
if(isNaN(phone))
alert("Characters are not allowed in the Phone Number");
else
alert("Your Phone Number is Accepted");
}
</script>
</head>
<body>
<form name="f1">
Phone: <input type="text" name="phone" size="20">
<input type="button" value="check" onclick="check()">
</form>
</body>
</html>
Labels:
function,
functions,
in,
isNaN,
javascript,
javascriptexample,
math
JavaScript: Squareroot Function
sqrt Function :-
Returns the square root of a number.
Suntax :-
sqrt(number)
Description :-
If the value of
number
is negative,sqrt
returns NaN
. Because sqrt
is a static method of Math
,you always use it as Math.sqrt()
, rather than as a method of a Math
object you created.Example:
<html>
<head>
<title>Calculate Squareroot</title>
<script language="javascript">
function calcsqrt()
{
var value=f1.sqrt.value;
alert("The Squareroot of " + value + " is " + Math.sqrt(value));
}
</script>
</head>
<body>
<form name="f1">
<input type="text" name="sqrt" value="Enter Number" size="20">
<input type="button" value="Calculate" onclick="calcsqrt()">
</form>
</body>
</html>
Labels:
function,
functions,
in,
javascript,
javascriptexample,
math,
sqrt,
squareroot
JavaScript: PI Function
PI:
The ratio of the circumference of a circle to its diameter, approximately 3.14159.
Description:
Because PI is a static property of Math, you always use it as Math.PI, rather than as a property of a Math object you created.
Example
<html>
<head>
<title>Calculate PI Value</title>
<script language="javascript">
document.write(Math.PI);
</script>
</head>
</html>
OUTPUT
3.141592653589793
Labels:
find,
function,
functions,
javascript,
javascriptexample,
math,
math.pi,
pi,
value
Javascript: FLOOR Function
floor function Returns the largest integer less than or equal to a number.
Syntax:
floor(a number)
Description:
Because floor is a static method of Math, you always use it as Math.floor(), rather than as a method of a Math object you created.
Example in HEAD Section
<html> <head> <title>Math.floor function</title> <script languag="javascript"> document.write("Pass value is -45.65 and return value is = " + Math.floor(45.65) + "<br>"); document.write("Pass value is -45.65 and return value is = " + Math.floor(-45.65)); </script> </head> </html> |
Example in BODY Section
<html> <head> <title>Math.floor function</title> </head> <body> <script languag="javascript"> document.write("Pass value is -45.65 and return value is = " + Math.floor(45.65) + "<br>"); document.write("Pass value is -45.65 and return value is = " + Math.floor(-45.65)); </script> </body> </html> |
OUTPUT
Pass value is -45.65 and return value is = 45
Pass value is -45.65 and return value is = -46
Labels:
example,
floor,
floorfunction,
function,
functionfloor,
functions,
javascript,
javascriptexample,
math,
on
Javascript: CEIL Function
ceil Function returns the smallest integer greater than or equal to a number.
Syntax:
ceil(a numebr)
Description:
Because ceil is a static method of math, you always use it as Math.ceil(), rather than as a method of a Math object you created.
Example in HEAD Section
<html> <head> <title>Math.ceil function</title> <script language="javascript"> document.write("Pass value is -45.65 and return value is = " + Math.ceil(45.65) + "<br>"); document.write("Pass value is -45.65 and return value is = " + Math.ceil(-45.65)); </script> </head> </html> |
Example in BODY Section
<html> <head> <title>Math.ceil function</title> </head> <body> <script language="javascript"> document.write("Pass value is -45.65 and return value is = " + Math.ceil(45.65) + "<br>"); document.write("Pass value is -45.65 and return value is = " + Math.ceil(-45.65)); </script> </body> </html> |
OUTPUT
Pass value is -45.65 and return value is = 46
Pass value is -45.65 and return value is = -45
Labels:
ceil,
ceilfunction,
examples,
examplesonjavascript,
function,
functions,
in,
javascript,
javascriptexample,
math,
on
Javascript: BIG Function
big Funtion
Causes a string to be displayed in a big font as if it were in a BIG tag.
Syntax:
big()
Description:
Use the big method with the write or write methods to format and display a string in a document. In server-side JavaScript, use the write function to display the string.
Example:
<html>
<head>
<title>Big function</title>
<script languge="javscript">
function makebig()
{
var name=f1.t1.value.big();
document.write(name);
}
</script>
</head>
<body>
<form name="f1">
<input type="text" name="t1" value="click" size="20">
<input type="button" onclick="makebig()" value="click">
</form>
</body>
</html>
Labels:
big,
example,
examples,
function,
functions,
in,
javascript,
javascriptexample,
math,
Math.big function
Subscribe to:
Posts (Atom)