stringMask('99988887766', '+7 (999) 9999-99-99')); // output: +7 (999) 8888-77-66
stringMask('99988887766', '+7 999 9999-99-99')); // output: +7 999 8888-77-66
stringMask('799988887766', '+7 999 9999-99-99')); // output: +7 999 8888-77-66
const stringMask = (phone, mask) => {};
function getNumberMask (number) {
var string = number.match(/^(\(?\+?\d{1,2}\)? ?\(?\d{1,3}\)? ?\d+\-? ?\d+\-? ?\d+)$/);
string = string[0];
var result = "";
for (var i =0;i<4;i++) {
result += string[i];
}
for (var i = 4; i<string.length;i++){
result += string[i].replace(string[i], "*");
}
return result;
}
console.log(getNumberMask("79502306392"))