changes all but the last four characters into '#'.

PHOTO EMBED

Wed Jun 15 2022 17:39:10 GMT+0000 (UTC)

Saved by @KhaledOghli #javascript #html

// return masked string
function maskify(cc) {
  const text = cc.replace(/\s/g,'').replace(/\w(?=\w{4})/gi,'#');
  return text
}
maskify('1')
content_copyCOPY

Usually when you buy something, you're asked whether your credit card number, phone number or answer to your most secret question is still correct. However, since someone could look over your shoulder, you don't want that shown on your screen. Instead, we mask it. Your task is to write a function maskify, which changes all but the last four characters into '#'.