Skip to content

Instantly share code, notes, and snippets.

function shuffle (action, inputString, optionalArgs) {
if (action && !parseInt(action)) throw 'invalid action type';
if (action < 1 || action > 4) throw 'action out of range';
if (action == 1) {
const end = inputString.slice(-1 * optionalArgs);
return end + inputString.slice(0, -1 * optionalArgs);
} else if (action == 2) {
return inputString.split('').reverse().join('');
} else if (action == 3) {
var n = 0; var x = '';