Random function problem ,need help

In this node, red I want to generate random number between 0-10 and if the number is less than 5 I want to output: the ((generated number from the function )) along with string message such as” less than 5”
for example :slight_smile: 4 less than 5
I can only output the generated number from the random function and I don’t know how to output string with it, I need help please.

What do you by 'along with'? Do you mean a single string containing the number and text, or you want the number and message separately in one message?


When I try to use (+) operator, I get an error as you see

yes mean single string containing the number and text.

You always need to return objects not variables.

But you should be able to concatenate within that object


number = 5;
msg.payload = “the number is :” + number;
return msg;

@sana_sabah86 - function debugging hint; do display sometthing in the debug log you can use:
node.warn("randon is: " + rnd);
and it will show with all the other debug messages.

it worked! thank you so much for your helo

thank you