Apologies in advance for any unclarities, I am extremely new to coding.
I found this code by Rick Pastoor (https://rickpastoor.com/2019/05/30/google-calendar-color-coder.html) to automatically colour code events in my Google Calendar based on what character the events start with (in this case !, [ and #).The code is for Google Apps Script
function ColorEvents() {
var today = new Date();
var nextweek = new Date();
nextweek.setDate(nextweek.getDate() + 7);
Logger.log(today + " " + nextweek);
var calendars = CalendarApp.getAllOwnedCalendars();
Logger.log("found number of calendars: " + calendars.length);
for (var i = 0; i < calendars.length; i++) {
var calendar = calendars[i];
var events = calendar.getEvents(today, nextweek);
for (var j = 0; j < events.length; j++) {
var e = events[j];
var title = e.getTitle();
if (title[0] == "[") {
e.setColor(CalendarApp.EventColor.CYAN);
}
if (title[0] == "!") {
e.setColor(CalendarApp.EventColor.RED);
}
if (title[0] == '#') {
e.setColor(CalendarApp.EventColor.GREEN);
}
}
}
}
Now instead of an event starting with !, I want it to colour code if an event starts with a word say:
if (title[0] == "Vacation") {
e.setColor(CalendarApp.EventColor.RED);
This however doesn't work. Anything with just one character (letters, numbers, signs) work, but more than 1 character doesn't work and I was wondering how I could solve this. Thank you in advance!