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

152
Views
Mapa Direcciones HTML y JS

Estoy tratando de hacer un mapa de un centro comercial con este script:

 <!DOCTYPE html> <html> <head> <title>Display Message</title> <script> // (B) CONFIRM function demoA() { let sgl = 'Target'; sgl; var destination1 = prompt("Enter Your Destination", " "); if (destination1 = sgl) { return true var location2 = prompt("Enter Your Closest Store", " ") alert("Starting Directions to " + destination1) } else { return false } } </script> </head> <body> <!-- (D) TEST BUTTONS --> <input type="button" value="Directions" onclick="demoA()" /> </body> </html>

Pero, cuando ejecuto esto, para la var destino1, pongo Target pero no me pregunta mi tienda más cercana. Otro problema es que estoy tratando de usar una cadena con el nombre de las tiendas, pero no puedo hacer que funcione.

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

La condición debe ser

 if (destination1 === sgl)

y no

 if (destination1 = sgl)

También después de esta línea tienes:

 return true

Y su función termina con la ejecución allí (no llegará a la siguiente línea)

about 4 years ago · Juan Pablo Isaza Report

0

Está regresando de la función antes de llamar al aviso por segunda vez aquí:

 let sgl = 'Target'; sgl; var destination1 = prompt("Enter Your Destination", " "); if (destination1 === sgl) { return true // this returns from the function and no following code is run var location2 = prompt("Enter Your Closest Store", " ") // never runs alert("Starting Directions to "+destination1) // never runs // put your return here to run the above } else { return false } }
about 4 years ago · Juan Pablo Isaza Report

0

Editar: ¡Buenas noticias! ¡Conseguí que funcionara gracias a @munleashed y @Tom! ¡Aquí está el nuevo código para aquellos que lo necesiten!

 <!DOCTYPE html> <html> <head> <title>Display Message</title> <script> // (B) CONFIRM function demoA () { let sgl = 'Target'; sgl; var destination1 = prompt("Enter Your Destination", " "); if (destination1 === sgl) { var location2 = prompt("Enter Your Closest Store", " ") // never runs alert("Starting Directions to "+destination1) // never runs return true // put your return here to run the above } else { return false } } </script> </head> <body> <!-- (D) TEST BUTTONS --> <input type="button" value="Directions" onclick="demoA()"/> </body> </html>
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!