You are viewing a single comment's thread. Return to all comments →
function capitalize(word) { return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase(); } function combineOperation(parts, indicator) { const camelCase = parts.map((part,index) => index === 0 ? part.toLowerCase() : capitalize(part)).join("") if (indicator === "M" || indicator === "V" ) return indicator === "M" ? camelCase + "()" : camelCase return parts.map(capitalize).join("") } function processData(input) { const parts = input.split("\r\n"); parts.forEach(part => { const [operate, indicator, string] = part.split(";") const cleanString = string.replace(/[^a-zA-Z\s]/g, ""); const ouput = operate === "S" ? cleanString.split(/(?=[A-Z])/).join(" ").toLowerCase() : combineOperation(cleanString.split(" "), indicator) console.info(ouput) }) } process.stdin.resume(); process.stdin.setEncoding("ascii"); _input = ""; process.stdin.on("data", function (input) { _input += input; }); process.stdin.on("end", function () { processData(_input); });
Seems like cookies are disabled on this browser, please enable them to open this website
Camel Case 4
You are viewing a single comment's thread. Return to all comments →