Using .indexOf() to define .getRange()

  google-apps-script, javascript

I am currently trying to use the .indexOf of a .getValues() array value, to define the cell I want a hyperlink copied in (as proof of concept).

Code looks as follows:

var descriptionColumn = headerArray[0].indexOf("Description")
sheet.getRange(sheet.getLastRow() + 1, descriptionColumn + 1).setFormula('=HYPERLINK(""; "Test")')

The headerArray is filled as follows:

var headerArray = sheet.getRange(1, 1, 1, lastColumn).getValues();

Now the log is showing me, that the descriptionColumn is being returned as "3.0". The position 3 is correct, yet I am unsure if the ".0" is messing with the next code. Because whenever I replace descriptionColumn in the .setFormula area, my code works. Any idea what I’m doing wrong and how to fix it? I am using .indexOf() in other places to refer to the index of another array without issue. Only here I don’t get it to work..

Thanks for any help. Cheers

Source: Ask Javascript Questions