Skip to content

Instantly share code, notes, and snippets.

@litanur
Created November 14, 2022 15:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save litanur/967b1100016a6b62d065249556d20b4c to your computer and use it in GitHub Desktop.
Save litanur/967b1100016a6b62d065249556d20b4c to your computer and use it in GitHub Desktop.
function checkProperties(obj, email) {
let fullname = "";
for (var key in obj) {
if (obj[key] !== null && obj[key] != "")
fullname = obj[key];
break;
}
if (fullname != "") {
console.log(fullname)
} else {
const regExp = /^([^@]+)/g;
fullname = email.match(regExp);
console.log(fullname[0]);
}
}
let obj = {
familyName: null,
givenName: null,
middleName: null,
namePrefix: null,
nameSuffix: null,
nickname: null}
let email = "litanur123@gmail.com";
checkProperties(obj, email)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment