What's wrong with this?

const Discord = require("discord.js");

exports.run = async(client, message, args) => {
  

  
  let cinsiyet = args[0];
if (cinsiyet.length < 1) return message.reply("cinsiyetini girmedin.")
  
  if (cinsiyet === "erkek" || cinsiyet === "kız")
    
    message.reply("teşekkürler.") 
  
}   else {
  
  
  
} 

I’m getting an error on else token. It says else is unexpected and I couldn’t solve this problem. Can you help me please?

if ... else can use statements or blocks, looks like you are mixing them together.

This is valid

if (conditionA)
    actionA
else
    actionNotA

And this is valid

if (conditionB) {
    actionB1
    actionB2
} else {
    actionNotB1
    actionNotB2
}
1 Like

Thank you. I’m in the half of the way. But now, I’m getting problem in this:

    if (cinsiyet !== ("e", "k")) return message.reply("lütfen cinsiyetinizi `e` ya da `k` şeklinde belirtin.")

I want to make a command that will only accept “e” or “k”.
When I use the command it accepts k but when I use “e” it returns. I also tried “[“e”, “k”]” this.

try:

if (cinsiyet !== “e” && cinsiyet !== “k”)

1 Like

Thanks but I already solved it.

     if (!["e", "k"].includes(args[0])) return message.reply("lütfen cinsiyetinizi `e` ya da `k` şeklinde belirtin.")