Cannot read properties of undefined (reading 'toString')
//To make sure that .toString() or .toUpperCase() doesn't throw an error,
//you could:
string = "" + string; // amends the value to an string, even if its undefined or null etc
//instead of:
string = string.toString();