The join()
function takes its second argument and inserts it in between each of the list items in the first argument. It will only accepts a list as its first argument and a string as its second argument.
join(list, string)
list.join(string)
Code language: JavaScript (javascript)
Note that Notion’s join()
function does not use a default separator (e.g. ,
), so you’ll always need to define one.
Good to know: non-string data types can be used in the second argument, but they will be automatically converted into strings. For example, join(["A", "B", "C"], 1)
will return "A1B1C"
Example Formulas
join(["Luffy", "Zoro", "Nami", "Chopper"], ", ")
/* Output: Luffy, Zoro, Nami, Chopper */
[1, 2, 3, 4].join("-") /* Output: "1-2-3-4" */
/* Use "\n" to add line breaks */
join(["Luffy", "Zoro", "Nami", "Chopper"], "\n")
/* Output:
Luffy
Zoro
Nami
Chopper */
Code language: JavaScript (javascript)