Created
November 14, 2022 15:05
-
-
Save litanur/967b1100016a6b62d065249556d20b4c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = "[email protected]"; | |
checkProperties(obj, email) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment