Shurikan117
Shurikan117

Reputation: 105

Illegal character Error in Google Code

I have been trying to run this code on Google scripts but running into the following error - Illegal character. (line 5, file "Code"). The code is below. Any help is truly appreciated.

Thanks!

function myFunction() {
 var d = new Date();
 var hours = d.getHours();
 var currentTime = d.toLocaleDateString();
 var counter = SpreadsheetApp.getActiveSheet().getRange(‘B1’).getValues();
 
 if (hours >= 6 && hours <= 18) {
 var response = UrlFetchApp.fetch(“https://recipe-qoo-api.herokuapp.com/");
 SpreadsheetApp.getActiveSheet().getRange(‘A’ + counter).setValue(‘Visted at ‘ + currentTime + “ “ + hours + “h”);
 SpreadsheetApp.getActiveSheet().getRange(‘B1’).setValue(Number(counter) + 1);
 }
}

Upvotes: 1

Views: 366

Answers (2)

vatsal mevada
vatsal mevada

Reputation: 5616

Looks like the character used for the single inverted quote is incorrect.

It should be like 'B1' instead of ‘B1’.

Upvotes: 1

LLL
LLL

Reputation: 1907

It's because you have wrong quotation marks, try " and '

Upvotes: 0

Related Questions