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

253
Visualizações
Converting Python to JS

I need help understanding how to convert some code from Python to JS. Basically, I am trying to ask a series of Y/N questions that follow along with a flowchart. I used if elif nested in python and it was suggested to me to use nested if blocks with JS but I'm not sure how to do that.

I am converting this flowchart questionnaire into a chatbot and there will be a yes or no button to click when each question appears and based on the answer another question will appear or the program will end. I hope this helps to explain my problem. Here is an example of the python code I have for ref that needs to be converted into JS:

question1 = input("Do you like the color green? Please select yes or no: ") 
if question1 == "yes": 
# Do this.
print("You have answered YES to the previous question")
if question1 == "yes":
    question2y = input("Do you like wearing green? Please select yes or no: ")
    if question2y == "yes":
        print("Thanks for taking the survey")
        
elif question1 == "no": 
# Do that.
print("You have answered NO to the previous question")
if question1 == "no":
    question2n = input("Do you like the color Blue? Please select yes or no: ")
    if question2n == "yes":
        print("You have answered YES to the previous question")

elif question2n == "no":
print("You have answered NO to the previous question")

else: 
print("Please select yes or no.")
about 4 years ago · Juan Pablo Isaza
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