The length()
function outputs a number that corresponds to the length of a string.
length(string)
length(list)
string.length()
list.length()
Code language: JavaScript (javascript)
Example Formulas
length("Monkey D. Luffy") /* Output: 15 */
length(["Batman", "Robin", "V", "Doctor Doom"]) /* Output: 4 */
"Supercalifragilisticexpialidocious".length() /* Output: 34 */
Code language: JavaScript (javascript)
Example Database
This example database used the length()
function to return the number of characters in the Name property. It also uses an if statement to intelligently output “character” or “characters”.
View and Duplicate Database
“Characters” Property Formula
let(
length, prop("Name").length(),
length
+ " character"
+ ifs(length != 1, "s")
)
/* Explained */
let(
/* Set a length variable with the length of the Name property value */
length, prop("Name").length(),
/* Display the length variable */
length
/* Add the " character" string */
+ " character"
/* Check if the length variable does not equal 1.
If it doesn't, add an "s" to the end of "character" */
+ ifs(length != 1, "s")
)
Code language: JavaScript (javascript)
This formula sets a length variable with the length of the Name property value. It then displays the value of the length variable and adds “ character” after it. Finally, if the value of length is not 0, it will add an “s” after “ character”.