In the continuation of the question asked HERE and a great reply by @Edvin I have following query.
The following code works great in my Google spreadsheet.
function onEdit(e) {
if (typeof e.value != 'object') {
if ([4, 5].indexOf(e.range.columnStart)<0) return;
e.range.setValue(titleCase(e.value));
}
}
function titleCase(str) {
return str.toString().split(/\b/).map(function(word) {
return word ? word.charAt(0).toUpperCase() + word.slice(1).toLowerCase() : '';
}).join('');
}
Is there any way I can add TRIM, CLEAN, Remove extra spaces between words like functions in this code.