Let's try mozilla's fixedCharAt function

This commit is contained in:
Chloe Fontenot 🏳️‍⚧️ 2023-04-30 22:56:54 -05:00
parent e0b3279cc1
commit 025ee853b0

View File

@ -217,25 +217,16 @@ function charIterate(input) {
let temp = input.split(''); let temp = input.split('');
for (let i = 0; i < stringLength; ++i) { for (let i = 0; i < stringLength; ++i) {
let compareString = temp.join(""); let compareString = temp.join("");
//console.log(surrogatePairs.exec(compareString), compareString);
let stringEval = undefined, stringEvalIndex = undefined; let stringEval = undefined, stringEvalIndex = undefined;
try {
while ((stringEval = surrogatePairs.exec(compareString)) !== null) { while ((stringEval = surrogatePairs.exec(compareString)) !== null) {
stringEvalIndex = stringEval.index; stringEvalIndex = stringEval.index;
//console.log("emoji is at index", stringEvalIndex); //console.log("emoji is at index", stringEvalIndex);
} }
} catch (e) {
console.log(e);
console.log("Handling exception...");
}
if (stringEvalIndex == i) { if (stringEvalIndex == i) {
stringLength--; stringLength--;
temp.splice(i, 1); temp.splice(i, 1);
//console.log("Decreasing stringLength variable to", stringLength); //console.log("Decreasing stringLength variable to", stringLength);
} }
} }
if (charIterateState == undefined) { if (charIterateState == undefined) {
console.log("undefined! setting to zero"); console.log("undefined! setting to zero");
@ -299,7 +290,7 @@ function design5(input) {
outputLine += fixedCharAt(input, charIterate(input)) + space + input + space + spaceOffset + fixedCharAt(input, charIterate(input)); outputLine += fixedCharAt(input, charIterate(input)) + space + input + space + spaceOffset + fixedCharAt(input, charIterate(input));
} }
//console.log(i, j, outputLine); console.log(i, j, outputLine);
if (lineHasInput) { if (lineHasInput) {
outputString += outputLine + "\n"; outputString += outputLine + "\n";
} }
@ -337,7 +328,7 @@ function fixedCharAt(str, idx) {
ret += str.charAt(idx + 1); ret += str.charAt(idx + 1);
} }
return ret; return ret;
} }
//console.log(design4("super long test string super long test string")); //console.log(design4("super long test string super long test string"));