This question already has an answer here:
I need to remove what is after the @
in an email address in a javascript var like that:
exemple@mail.com
to exemple
for example, how I can make that because I have seen the function
Math.trunc()
But to replace the user.DisplayName
by the truncated email with in my code :
var user = user.DisplayName;
var email = user.email;
if (user === null ) {
//truncate email (user.email)
$(user).text(displayName);
}
else {
//...
}