Guest User

Untitled

a guest
Nov 22nd, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. var max = 0
  2. var num
  3. num = prompt("Enter new value, or 0 to end")
  4. while (num != 0) {
  5. if (parseFloat(num) > max)
  6. max = num
  7. num = prompt("Enter new value, or 0 to end")
  8. }
  9. document.write("<P> Max = " + max)
  10.  
  11. **** SHORTHAND ****
  12.  
  13. var max = 0
  14. var num = prompt("Enter new value, or 0 to end")
  15. while (num != 0) {
  16. if (parseFloat(num) > max)
  17. max = num
  18. num = prompt("Enter new value, or 0 to end")
  19. }
  20. document.write("<P> Max = " + max)
  21.  
  22.  
  23. /*
  24. The parseFloat() function parses an argument and returns a floating point number.
  25. parseFloat is a top-level function and is not associated with any object.
  26.  
  27. parseFloat parses its argument, and returns a floating point number.
  28. If it encounters a character other than a sign (+ or -), numeral (0-9), a decimal point, or an exponent,
  29. it returns the value up to that point and
  30. ignores that character and all succeeding characters. Leading and trailing spaces are allowed.
  31.  
  32. If the value is a string and first character cannot be converted to a number,
  33. parseFloat returns NaN.
  34.  
  35. For arithmetic purposes, the NaN value is not a number in any radix.
  36. You can call the isNaN function to determine if the result of parseFloat is NaN.
  37. If NaN is passed on to arithmetic operations, the operation results will also be NaN.
  38.  
  39. parseFloat can also parse and return the value Infinity.
  40. You can use the isFinite function to
  41. determine if the result is a finite number (not Infinity, -Infinity, or NaN).
  42. */
Add Comment
Please, Sign In to add comment