RosettaCodeData/Task/Strip-a-set-of-characters-from-a-string/JavaScript/strip-a-set-of-characters-from-a-string-2.js
2023-07-01 13:44:08 -04:00

21 lines
506 B
JavaScript

(() => {
'use strict';
// stripChars :: String -> String -> String
const stripChars = (strNeedles, strHayStack) =>
strHayStack.replace(RegExp(`[${strNeedles}]`, 'g'), '');
// GENERIC FUNCTION
// curry :: ((a, b) -> c) -> a -> b -> c
const curry = f => a => b => f(a, b);
// TEST FUNCTION
const noAEI = curry(stripChars)('aeiAEI');
// TEST
return noAEI('She was a soul stripper. She took my heart!');
// 'Sh ws soul strppr. Sh took my hrt!'
})();