|
|
Math Object and JavaScript Input Message
The Math object provides additional and more complex mathematical operations than the basic ones (+, -, *, /). We also show how to input data using Prompt method. After completion of this page you should be able to program your own special purpose calculator for must analog scientific calculations.
Syntax Output Math.abs(value)
Absolute value
Prompt method of inputing information: Note the the parseInt() statement tells the program to interpret text entered in box as a Integer. var text = prompt
("Enter decimal number for var x ","") Note the the parseFloat() statement tells the program to interpret text entered in box as a decimal (floating point) number. Program below uses both the Math Object and inputs two variables. Copy program to Notepad and then run using Internet Explorer as we did on previous page. The following program raises a number x to the power of an integer N. <HTML> Back to: First JavaScript Program View Demo of Code Advance to Parallel Resistors
You may have noticed that the calculators that you have seen on the Internet use form not popups to input and output data. If you wish to learn how to use a form, go to Calculator Format. This will complicate the lesson and is strictly optional.
|
|
|