1
const i = [1 || 2]
if (!message.channel.name.includes(o['opts' + i].identity.username.toLowerCase())) return message.channel.send('do commands only at <#bot-commands-id>');
console.log('oke');

How can I assign multiple values ​​to variable?

const i = [1 || 2 || 3 || 4 || 5]

as

4
  • You're looking for a loop and/or an array. Commented May 1, 2022 at 15:41
  • sort of can you answer Commented May 1, 2022 at 15:59
  • "Sort of"? Why not? Do you know what arrays and loops are already? What exactly do you want to do with the multiple values? Commented May 1, 2022 at 16:18
  • If those values ​​are equal, I want to open a channel. Commented May 1, 2022 at 16:33

1 Answer 1

1

You just have to Use an array , and you do your condition with i[index] accessing all indexs with a for loop.

In your case is :

const i = [1 ,2 ];
for (let j = 0 , j <= i.length , j++) {
   if (!message.channel.name.includes(o['opts' + i[j]].identity.username.toLowerCase())) return message.channel.send('do commands only at <#bot-commands-id>');
   console.log('oke');
}
Sign up to request clarification or add additional context in comments.

3 Comments

Given how the if statement returns from the function, this is probably not what the OP wants
syntaxerror: identifier "j" has already been declared
if you alrdy used j as variable just change it to a unused name

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.