Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

203
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!