Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

205
Visualizações
How to repeat if statement multiple times in a while loop

I’m creating an bot that will play a card game in which you need to guess if the value of the next card is going be higher, lower or equal.

I want to always guess whether the first and second cards are going to be equal (which will give me 12 points). I have no problem doing that, but after that I want the bot to follow the safer way in guessing the cards. I also have the option to skip cards.

Here is my code and I will describe the issue I’m having:

while (currentMulti >= 12) {
    if (lastCard == "K" || lastCard == "J" || lastCard == "Q" || lastCard == "10" || lastCard == "9") {
        nextGuessLow(lastCard)
        lastCard = nextGuessLow.lastCard
        currentMulti = nextGuessLow.currentMulti
    } else if (lastCard == "A" || lastCard == "2" || lastCard == "3" || lastCard == "4" || lastCard == "5") {
        nextGuessHigh(lastCard)
        lastCard = nextGuessHigh.lastCard
        currentMulti = nextGuessHigh.currentMulti
    } else {
        nextGuessSkip(lastCard)
        lastCard = nextGuessSkip.lastCard
        currentMulti = nextGuessSkip.currentMulti
    }
}

The problem is that the script/bot only guesses if the 3rd card is going to be lower or high one time, and after guessing the 3rd card it goes back to guessing the next cards (4th, 5th) and so on as equal. What can the issue be? If I need to add the rest of the code that includes the equal guess part then please let me know.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Ok i figured out what the problem was, actually an very rookie mistake by me lol, the lastCard and currentmulti values need to be returned with an await operator, i was trying to call it without the await which it was kinda glitching and not returning the value i needed

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda