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

214
Views
If statement is executing when it shouldn't
function RegisterAction() {
        let saveSub = buyMore(0);
        let askbuyMore = prompt("Do you want to buy more? Y/N ");
        if(askbuyMore === "Y"||"y"||"Yes"||"yes"){
            saveSub = buyMore(saveSub);
            askbuyMore = prompt("Do you want to buy more? Y/N ");
        }else{
            return saveSub;
        }
        const caSalesTax = .0725;
        let caSalesTaxPercent = Math.round((caSalesTax*100)*100)/100;
        let registerTax = console.log(`California sales Tax is ${caSalesTaxPercent}%`);
        registerTax;
        let finalTotalRounded = Math.round(100*(saveSub*caSalesTax+saveSub))/100;
        let registerTotal = console.log(`Your final total with tax is $${finalTotalRounded}.`);
        registerTotal;
    }

Why is the if statement executing on first attempt when i aswer askbuyMore prompt with "n"?

about 4 years ago · Juan Pablo Isaza
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!