This is a simple Node.js package that allows you to create strings that alternate in case.
To start using this package, simply install from NPM:
npm install alternating-case --saveAfter installation, you can just require the package to use it:
const altCase = require("alternating-case");This package exports a single function:
altCase(input, capsOnOdds);The first argument, input is the string you are trying to manipulate. While by default capital letters will be on odd characters, you can make it capitalize even characters instead by changing the second argument, capsOnOdds, to false.
altCase("hello"); // "HeLlO"
altCase("should we capitalize odd characters?"); // "ShOuLd wE CaPiTaLiZe oDd cHaRaCtErS?"
altCase("should we capitalize odd characters?", true); // "ShOuLd wE CaPiTaLiZe oDd cHaRaCtErS?"
altCase("should we capitalize odd characters?", false); // "sHoUlD We cApItAlIzE OdD ChArAcTeRs?"
altCase("The quick, brown fox jumps over the lazy dog."); // "ThE QuIcK, bRoWn fOx jUmPs oVeR ThE LaZy dOg."
altCase("No need to worry; áccents are preserved."); // "No nEeD To wOrRy; ÁcCeNtS ArE PrEsErVeD."Have fun!