A1:
{ let DEFAULT_START = 0; let DEFAULT_STEP = 1; window.mylib.range = function (start, stop, step) { let arr = []; if (!step) { step = DEFAULT_STEP; } if (!stop) { stop = start; start = DEFAULT_START; } if (stop < start) { // reverse values let tmp = start; start = stop; stop = tmp; } for (let i = start; i < stop; i += step) { arr.push(i); } return arr; } }
{ const DEFAULT_START = 0; const DEFAULT_STEP = 1; window.mylib.range = function (start, stop, step) { const arr = []; if (!step) { step = DEFAULT_STEP; } if (!stop) { stop = start; start = DEFAULT_START; } if (stop < start) { // reverse values const tmp = start; start = stop; stop = tmp; } for (let i = start; i < stop; i += step) { arr.push(i); } return arr; } }
function maskEmail(email, mask) { if (!email.includes('@')) { throw new Error('Invalid Email'); } if (!mask) { mask = '*'; } const atIndex = email.indexOf('@'); const masked = mask.repeat(atIndex); const tld = email.substr(atIndex); return masked + tld; }