Correctly Capatilize After Opening Bracket

Working and tested
This commit is contained in:
Jera 2021-08-31 23:45:16 -04:00
parent 0019c9656b
commit 8125a31fce

View file

@ -25,9 +25,13 @@ function changeCase(txt, type){
case 'upper': return txt.toUpperCase()
case 'start':
txt = txt.split(" ")
for (let i = 0, q = 0; i < txt.length; i++)
if (txt[i].substr(0, 1) === "(" || txt[i].substr(0, 1) === "[" || txt[i].substr(0, 1) === "{") q++;
txt[i] = txt[i][q].toUpperCase() + txt[i].substr(q + 1).toLowerCase()
for (let i = 0; i < txt.length; i++) {
if (txt[i].startsWith("(") || txt[i].startsWith("[") || txt[i].startsWith("{")) {
txt[i] = txt[i][0] + txt[i][1].toUpperCase() + txt[i].substr(2).toLowerCase()
} else {
txt[i] = txt[i][0].toUpperCase() + txt[i].substr(1).toLowerCase()
}
}
return txt.join(" ")
case 'sentence': return txt.charAt(0).toUpperCase() + txt.slice(1).toLowerCase()
default: return txt