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

163
Views
If-statment - import answer from a earlier function()

We want to import the answer from the animal function to the if-stament- how do we do that?

const animal = (msg) => {
  questionNumber++;
  botReply(`Nice to meet you ${msg}. Do you like pandas, elefants or koalas?`);

  inputWrapper.innerHTML = `
  <button id="tiger">Tiger</button>
  <button id="elefants">Elefants</button>
  <button id="bears">Bears</button>
`;

  document
    .getElementById("tiger")
    .addEventListener("click", () => nextQuestion("tiger"));

  document
    .getElementById("elefants")
    .addEventListener("click", () => nextQuestion("elefants"));

  document
    .getElementById("bears")
    .addEventListener("click", () => nextQuestion("bears"));
};
const showMenu = (type) => {
  questionNumber++
  questionNumber++;
  
  botReply(`oh good choice ${type}? Do you like warm placese or cold?`);
    inputWrapper.innerHTML = `
  inputWrapper.innerHTML = `
    <button id="cold">Cold</button>
   
  `
  `;
    document
  document
    .getElementById("warm")
    .addEventListener("click", () => nextQuestion("warm"));

  document
    .getElementById("cold")
    .addEventListener("click", () => nextQuestion("cold"));
};

const showDishSize = (type, animal) => {
  questionNumber++;

  /*  Elefant */

  if (type === "warm" && animal === "elefants") {
    botReply(
      `oh good choice, you like warm weather and elefants! You should go to India!"`
    );
  } else if (type === "cold" && animal === "elefants") {
    botReply(
      `oh good choice, you like cold weather and elefants! You should go to China!"`
    );
  } else if (type === "warm" && animal === "tiger") {

  /*  Tiger */
    botReply(
      `oh good choice, you like warm weather and tiger! You should go to India!"`
    );
  } else if (type === "cold" && animal === "tiger") {
    botReply(
      `oh good choice, you like cold weather and tiger! You should go to Russia!"`
    );
  } else if (type === "warm" && animal === "bears") {

  /*  Bears */
    botReply(
      `oh good choice, you like warm weather and bears! You should go to Africa!"`
    );
  } else {
    botReply(
      `oh good choice, you like cold weather and bears! You should go to Sweden!"`
    );
  const showDishSize = (type, animal) => {
};

Thank you :)

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!