I also have a null-checking question that might be similar to this. I want to show the profile.middleName
field if it exists for someone, but remove it if the field is empty. I tried to add the field to the name in the “title:” like the first and last names but if it doesn’t exist it appears as “undefined”. How do I resolve this?
EDIT: I was able to fix this using our regular null-checking training here, and made it so that if there is content in the middle name field ? show firstName middleName lastName : but if there’s none, show firstName lastName. Here’s what I used:
title: profile.middleName ? `${profile.firstName} ${profile.middleName} ${profile.lastName}` : `${profile.firstName} ${profile.lastName}`,