lets

Assigns values to multiple variables and evaluates the expression using those variables.
Accepts
Returns
Syntax
lets(variable, value, variable2, value2, ..., expression) variable.lets(value, variable2, value2, ..., expression)

lets(
    a, "Hello",
    b, " world!",
    [a, b].join(" ")
)lets(

    /* Create an 'a' variable and assign it the string "Hello" */
    a, "Hello",

    /* Create a 'b' variable and assign it the string " world!" */
    b, " world!",

    /* Combine the 'a' and 'b' variable values together with + */
    [a, b].join(" ")
    
)
=
Hello world! "Hello world!"

 

lets(
    a, "Hello",
    b, " world!",
    [a, b].join(" ")
)lets(

    /* Create an 'a' variable and assign it the string "Hello" */
    a, "Hello",

    /* Create a 'b' variable and assign it the string " world!" */
    b, " world!",

    /* Combine the 'a' and 'b' variable values together with + */
    [a, b].join(" ")
    
)
=
Hello world! "Hello world!"
lets(
	date, prop("Date").dateAdd(1, "months"),
	lastDay, date.dateSubtract(date.date(), "days"),
	lastDay.day().test("6|7")
		? lastDay.dateSubtract(-5 + lastDay.day(), "days") 
		: lastDay
)
lets(
	range, 
	prop("Dates").dateStart() != prop("Dates").dateEnd(),
	from, 
	range && prop("Dates").dateStart().test("AM|PM") 
		? prop("Dates").dateStart().formatDate("h:mm A") 
		: "",
	to, 
	range && prop("Dates").dateEnd().test("AM|PM") 
		? prop("Dates").dateEnd().formatDate("h:mm A") 
		: "",
	(from ? from : "")
	+ (from && to ? " → " + to : "")
)lets(

	/* Check if the start and end dates of Dates don't 
	match, 	and assign the result to a 'range' variable */
	range, 
	prop("Dates").dateStart() != prop("Dates").dateEnd(),

	from, 
	range && prop("Dates").dateStart().test("AM|PM") 
		? prop("Dates").dateStart().formatDate("h:mm A") 
		: "",

	to, 
	range && prop("Dates").dateEnd().test("AM|PM") 
		? prop("Dates").dateEnd().formatDate("h:mm A") 
		: "",
    
	(from ? from : "") 
    + (from && to ? " → " + to : "")
    
)
=
9:00 AM → 6:00 PM "9:00 AM → 6:00 PM"