denverpost
Version:
Undo that silly encoding.
29 lines (23 loc) • 609 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = exports.decode = void 0;
var decode = function decode(str) {
var length = str.length;
var out = '';
for (var i = 0; i < length; i++) {
var shouldDecode = /[a-z]/i.test(str[i]);
if (shouldDecode) {
var code = str.charCodeAt(i);
var shifted = code - 1;
out = "".concat(out).concat(String.fromCharCode(shifted));
} else {
out = "".concat(out).concat(str[i]);
}
}
return out;
};
exports.decode = decode;
var _default = decode;
exports["default"] = _default;