Change color of a function return JavaScript

In JavaScript
How can i change the colors of a text from a html text replaced by function parameter, directly from an external condition.
If i have an input that must be filled with a message, as a parameter of my function, then it replaces a text from the html.
i don’t know how to directly apply styles to the function.
Then i want two conditions to determinate the color of the message:
example:
condition 1 = true => green
condition 2 = true => red
How can i do that?
i can’t find a solution