|
January 15, 2000 Comparing Numeric Strings Tips: January 2000
Yehuda Shiran, Ph.D.
|
|
When you accept user's inputs via a form, you end up with string data. More often than not you may want to compare two numeric items. The built-in parseInt() function converts a numeric string to an integer. The following example shows how to use it:
The script's output is:
If a non-integer numeric string is given to the function, it returns the nearest integer, as a number.
See more examples for using the
People who read this tip also read these tips: Look for similar tips by subject: |