I was trying to create a function that takes a number of minutes and outputs it in a nice readable format. For instance, FORMATMINUTES(1570)
would output 1d2h10m
, but I got hung up trying to find a truncate function. I also had to change my let
s to var
s. Is there a reference that tells you what javascript features are available when writing custom functions?
To simplify I created two functions. First, the Math.trunc()
function doesn't seem to exist as it doesn't show up as a suggestion and throws an error when used:
function MYTRUNC(input) {
return Math.trunc(input);
}
Second I thought that maybe I could use sheets's built-in TRUNC
function, but that isn't defined either:
function MYTRUNC2(input) {
return TRUNC(input)
}
I read google's guide but it says "Custom functions are created using standard JavaScript" but not what version of javascript. Apparently it doesn't support let
.
Their app scripts reference has a lot of information on interacting with sheets, but not a basic or complete reference. I realize that in this situation I can use Math.floor
which is available or subtract input % 1
, but I'd like to know what other idiosyncrasies there might be, and if I can use newer javascript features. Template literals give an error as well, so maybe it's based on an earlier javascript version?