I have a Typescript project in which I need to build a dynamic if from the data I receive from the object, I have to add as many conditions as properties the object has.
This is the object:
interface EmailParams {
sender?: string,
subject?: string,
fileType?: string
}
let params: EmailParams = {
sender: "test@gmail.com"
}
This is what I need:
if (test1.from.toUpperCase() == params.sender?.toUpperCase())
But if the object changes, this is a new object:
interface EmailParams {
sender?: string,
subject?: string,
fileType?: string
}
let params: EmailParams = {
sender: "test@gmail.com",
subject: "data"
}
This should be the new if:
if (test1.from.toUpperCase() == params.sender?.toUpperCase() &&
test1.data.toUpperCase() == params.subject?.toUpperCase()
)