Creates a variable with given starting value. Type is determined dynamically.
- stringVar = prompt("message")
Sends message to user in a dialog box, retrieves text input from user and stores it in stringVar.
Returns the length (in characters) of stringVar.
- stringVar.toUpperCase(), stringVar.toLowerCase()
Converts stringVar to upper- or lowercase.
Returns a specified subset of stringVar.
Returns location of a substring in stringVar (or -1).
Converts string to int.
Converts string to float.
Converts any variable to string.
Evaluates string as JavaScript code.
Converts any number to integer by rounding up.
Converts any number to integer by rounding down.
Converts any number to integer by standard rounding algorithm.
Returns random float between 0 and 1.
Creates a popup dialog containing "message."
- stringVar = prompt("message")
Send message to user in a dialog box, retrieve text input from user and store it in stringVar.
Operators
- Equality == (x==3) - Works with all variable types, including strings.
- Not equal != (x != 3) - True if values are not equal.
- Less than < (x < 3) - Numeric or alphabetical comparison.
- Greater than > (x > 3) - Numeric or alphabetical comparison.
- Less than or equal to <= (x <= 3) - Numeric or alphabetical comparison.
- Greater than or equal to >= (x >= 3) - Numeric or alphabetical comparison.