Is there a way to force .getRange().getValues() to return an int? Although only numbers exist in my range, it is returning them as strings. I would like to avoid using parseInt in every one of my statements or creating a separate array with converted values.
Or is that the only solution, to get the array and then parseInt the entire array in a loop?
parseInt() returns a number, that's all you need.
Under Run, select the name of function you want to trigger. Under Events, select either Time-driven or the Google App that the script is bound to (for example, From spreadsheet). Select and configure the type of trigger you want to create (for example, an Hour timer that runs Every hour or an On open trigger).
A protected range can protect either a static range of cells or a named range. A protected sheet may include unprotected regions. For spreadsheets created with the older version of Google Sheets, use the PageProtection class instead. // Protect range A1:B10, then remove all other users from the list of editors.
you can do this easily using the unary '+' operator as follows:
First get your values from your spreadsheet using getValue()
or getValues()
. Suppose you get two such values, and store them in A = 1
and B = 2
. You can force them to be recognized as numbers by using any math binary operator except for +
, which concatenates strings, so A - B = -1
, while A + B
will return '12'.
You can force the variables to be numbers simply by using the +
unary operator with any variable that might be interpreted as a string. For example, +A + +B
will return the correct value of 3.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With