JSFiddle - React, Tailwind, and code Playground
by inabahare
HTML
<p class="result"></p>
JavaScript
const sentence = `
- 0.12 and 0.17 are so close that you only have things shorthand 2. It will semantically make more sense.
- With the above in mind, you're doing your comparison 2k times. Like you're sacrificing readability and scalability for 0.05? Like that's what they mean by premature optimizaiton being the root of all evil
- Those are milliseconds. Like 2k runs in 0.17 milliseconds.. Like that's not a lot of time at all
`;
const likeRemover = /(Like\ )(.)/g;
const matches = sentence.matchAll(likeRemover);
const result =
Array.from(matches)
.reduce((res, match) =>
res.replace(match[0], match[2].toLocaleUpperCase()), sentence);
document.querySelector(".result").innerText = result;