How to do a random pick of responses in JavaScript

Hey there,
I just started with JavaScript and have no idea for what to search in my case. So sorry if this had been aswered or asked before!

I made a discord bot with Eclipse. Everything is working so far, the bot is responding to various commands.

Now I want to do a command like “Hello!” and the bot randomly picks an answer from 4 different response options. Like:

Hello!
Possible answers: Hello
Good Morning
Hello, how are you?
Hi!

And once a user typed “hello!” in the channel the bot will pick one of the responses. Writing “hello!” again will pick another answer.

How to do that? I know there isn’t an “Either” command in JavaScript so I am a little helpless and I’d be really happy for help.

Thank you!

I don’t know much at all about programming bots, so I don’t know if this will help or not.

I am familiar with JavaScript though and in order to achieve this goal I would write something along the lines of:

const responses = ['Hello','Good Morning', 'Hello, how are you?', 'Hi!'];
const respond = () => responses[Math.floor(Math.random() * responses.length)]
if (true) respond()

There is an or operator in programming you may not be aware of. To access it you use || known as pipes.

Hope this helps you find the issue!