Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var max = 0
- var num
- num = prompt("Enter new value, or 0 to end")
- while (num != 0) {
- if (parseFloat(num) > max)
- max = num
- num = prompt("Enter new value, or 0 to end")
- }
- document.write("<P> Max = " + max)
- **** SHORTHAND ****
- var max = 0
- var num = prompt("Enter new value, or 0 to end")
- while (num != 0) {
- if (parseFloat(num) > max)
- max = num
- num = prompt("Enter new value, or 0 to end")
- }
- document.write("<P> Max = " + max)
- /*
- The parseFloat() function parses an argument and returns a floating point number.
- parseFloat is a top-level function and is not associated with any object.
- parseFloat parses its argument, and returns a floating point number.
- If it encounters a character other than a sign (+ or -), numeral (0-9), a decimal point, or an exponent,
- it returns the value up to that point and
- ignores that character and all succeeding characters. Leading and trailing spaces are allowed.
- If the value is a string and first character cannot be converted to a number,
- parseFloat returns NaN.
- For arithmetic purposes, the NaN value is not a number in any radix.
- You can call the isNaN function to determine if the result of parseFloat is NaN.
- If NaN is passed on to arithmetic operations, the operation results will also be NaN.
- parseFloat can also parse and return the value Infinity.
- You can use the isFinite function to
- determine if the result is a finite number (not Infinity, -Infinity, or NaN).
- */
Add Comment
Please, Sign In to add comment