SlideShare una empresa de Scribd logo
Ejercicios
1. Pide la edad y si es mayor de 18 años
indica que ya puede conducir.
<script> //PIDE POR TECLADO LA EDAD
var edad = prompt("Introduce tu edad");
//COMPRUEBA QUE LO INTRODUCIDO ES UN NÚMERO
if (Number(edad) == edad) {
//SI ES MAYOR DE 18
if (edad > 18) {
//IMPRIME EN PANTALLA EL MENSAJE
document.write("Puedes conducir"); } }
//SINÓ
else {
//MUESTRA UN MENSAJE
alert("Introduce un numero válido"); }
</script>
2. Pide una nota (número). Muestra la calificación
según la nota:
0-3: Muy deficiente
3-5: Insuficiente
5-6: Suficiente
6-7: Bien
7-9: Notable
9-10: Sobresaliente
<script> //BUCLE PARA QUE PERMITA INTRODUCIR MÁS DE UNA NOTA
do {
//PIDE UNA NOTA POR TECLADO Y LA GUARDA EN LA VARIABLE nota
var nota = prompt("Introduce tu nota");
//SI SE INTRODUJO UN NÚMERO
if (Number(nota) == nota) {
//SI LA NOTA ES ENTRE 0 Y 10 COMPRUEBA EL RANGO Y DA UN MENSAJE
if (nota > 0 && nota <= 10) {
if (nota < 3) {
alert("Muy deficiente"); }
else if (nota < 5) {
alert("Insuficiete"); }
else if (nota < 6) {
alert("Suficiente"); }
else if (nota < 7) {
alert("Bien"); }
else if (nota < 9) {
alert("Notable"); 5 }
else if (nota >= 9) {
alert("Sobresaliente"); } }
//SI LA NOTA NO ES ENTRE 0 Y 10
else {
alert("Nota erronea"); } }
//SI LA NOTA INTRODUCIDA NO ES UN NÚMERO
else {
//SI SE HA PULSADO ACEPTAR SIN INTRODUCIR NADA
if (nota != undefined) {
//No es Undefined cuando se pulsa aceptar.
alert("Introduce un numero valido"); } }
//EL BUCLE VUELVE ARRIBA MIENTRAS NO SE HAYA PULSADO CANCELAR }
while (nota != undefined);
//Undefined es cuando se pulsa Cancelar.
</script>
3. Realiza un script que pida cadenas de
texto hasta que se pulse “cancelar”. Al salir con
“cancelar” deben mostrarse todas las cadenas
concatenadas con un guión -.
<script> //DECLARAMOS UNA VARIABLE DONDE VAMOS A CONCATENAR LAS CADENAS
var resultado = "";
//BUCLE DO WHILE PARA INTRODUCIR VARIAS CADENAS
do {
//PEDIMOS LA CADENA POR TECLADO
var cadena = prompt("Introduce una cadena");
//SI LA VARIABLE RESULTADO ESTÁ VACÍA
if (resultado == "") {
//CONCATENAMOS SIN UTILIZAR GUIÓN
resultado = resultado + cadena; }
//SINÓ
else {
//CONCATENAMOS CON GUIÓN
resultado = resultado + "-" + cadena; }
//MIENTRAS SE PULSE ACEPTAR EN EL MENSAJE EMERGENTE CONFIRM }
while (confirm("Desea seguir?"));
//SI SE PULSÓ CANCELAR IMPRIMIMOS EL RESULTADO
document.write(resultado); </script>

Más contenido relacionado

La actualidad más candente

SSL certificates in the Oracle Database without surprises
SSL certificates in the Oracle Database without surprisesSSL certificates in the Oracle Database without surprises
SSL certificates in the Oracle Database without surprisesNelson Calero
 
Pl sql student guide v 1
Pl sql student guide v 1Pl sql student guide v 1
Pl sql student guide v 1Nexus
 
ProstgreSQLFailoverConfiguration
ProstgreSQLFailoverConfigurationProstgreSQLFailoverConfiguration
ProstgreSQLFailoverConfigurationSuyog Shirgaonkar
 
Consultas sql
Consultas sqlConsultas sql
Consultas sqlUNACAR
 
Ejercicio - Personal de departamentos (XSD - XML Schema)
Ejercicio - Personal de departamentos (XSD - XML Schema)Ejercicio - Personal de departamentos (XSD - XML Schema)
Ejercicio - Personal de departamentos (XSD - XML Schema)Abrirllave
 
İleri Seviye T-SQL Programlama - Chapter 04
İleri Seviye T-SQL Programlama - Chapter 04İleri Seviye T-SQL Programlama - Chapter 04
İleri Seviye T-SQL Programlama - Chapter 04Cihan Özhan
 
Uploading certificate with oracle wallet manager and orapki utilities
Uploading certificate with oracle wallet manager and orapki utilitiesUploading certificate with oracle wallet manager and orapki utilities
Uploading certificate with oracle wallet manager and orapki utilitiesÖzgür Umut Vurgun
 
Creating new service name for oracle database
Creating new service name for oracle databaseCreating new service name for oracle database
Creating new service name for oracle databaseRavi Kumar Lanke
 
İleri Seviye T-SQL Programlama - Chapter 09
İleri Seviye T-SQL Programlama - Chapter 09İleri Seviye T-SQL Programlama - Chapter 09
İleri Seviye T-SQL Programlama - Chapter 09Cihan Özhan
 
Hyperion 11-1-2-3-installation-guide-on-linux
Hyperion 11-1-2-3-installation-guide-on-linuxHyperion 11-1-2-3-installation-guide-on-linux
Hyperion 11-1-2-3-installation-guide-on-linuxAmit Sharma
 
İleri Seviye T-SQL Programlama - Chapter 05
İleri Seviye T-SQL Programlama - Chapter 05İleri Seviye T-SQL Programlama - Chapter 05
İleri Seviye T-SQL Programlama - Chapter 05Cihan Özhan
 
İleri Seviye T-SQL Programlama - Chapter 16
İleri Seviye T-SQL Programlama - Chapter 16İleri Seviye T-SQL Programlama - Chapter 16
İleri Seviye T-SQL Programlama - Chapter 16Cihan Özhan
 
phpMyAdmin con Xampp
phpMyAdmin con XamppphpMyAdmin con Xampp
phpMyAdmin con XamppLeccionesWeb
 
SAP ABAP Latest Interview Questions with Answers by Garuda Trainings
SAP ABAP Latest Interview Questions with Answers by Garuda TrainingsSAP ABAP Latest Interview Questions with Answers by Garuda Trainings
SAP ABAP Latest Interview Questions with Answers by Garuda TrainingsGaruda Trainings
 
Trigger and cursor program using sql
Trigger and cursor program using sqlTrigger and cursor program using sql
Trigger and cursor program using sqlSushil Mishra
 
İleri Seviye T-SQL Programlama - Chapter 12
İleri Seviye T-SQL Programlama - Chapter 12İleri Seviye T-SQL Programlama - Chapter 12
İleri Seviye T-SQL Programlama - Chapter 12Cihan Özhan
 
넥슨 글로벌 플랫폼 구축 이야기 : DB Migration case study (임현수 플랫폼인프라실 Technical Manager, 넥...
넥슨 글로벌 플랫폼 구축 이야기 : DB Migration case study (임현수 플랫폼인프라실 Technical Manager, 넥...넥슨 글로벌 플랫폼 구축 이야기 : DB Migration case study (임현수 플랫폼인프라실 Technical Manager, 넥...
넥슨 글로벌 플랫폼 구축 이야기 : DB Migration case study (임현수 플랫폼인프라실 Technical Manager, 넥...Amazon Web Services Korea
 
09 Managing Dependencies
09 Managing Dependencies09 Managing Dependencies
09 Managing Dependenciesrehaniltifat
 

La actualidad más candente (20)

Tabla comparativa entre bases de datos sql y nosql
Tabla comparativa entre bases de datos sql y nosqlTabla comparativa entre bases de datos sql y nosql
Tabla comparativa entre bases de datos sql y nosql
 
SSL certificates in the Oracle Database without surprises
SSL certificates in the Oracle Database without surprisesSSL certificates in the Oracle Database without surprises
SSL certificates in the Oracle Database without surprises
 
Pl sql student guide v 1
Pl sql student guide v 1Pl sql student guide v 1
Pl sql student guide v 1
 
ProstgreSQLFailoverConfiguration
ProstgreSQLFailoverConfigurationProstgreSQLFailoverConfiguration
ProstgreSQLFailoverConfiguration
 
Consultas sql
Consultas sqlConsultas sql
Consultas sql
 
Ejercicio - Personal de departamentos (XSD - XML Schema)
Ejercicio - Personal de departamentos (XSD - XML Schema)Ejercicio - Personal de departamentos (XSD - XML Schema)
Ejercicio - Personal de departamentos (XSD - XML Schema)
 
Best sql plsql material
Best sql plsql materialBest sql plsql material
Best sql plsql material
 
İleri Seviye T-SQL Programlama - Chapter 04
İleri Seviye T-SQL Programlama - Chapter 04İleri Seviye T-SQL Programlama - Chapter 04
İleri Seviye T-SQL Programlama - Chapter 04
 
Uploading certificate with oracle wallet manager and orapki utilities
Uploading certificate with oracle wallet manager and orapki utilitiesUploading certificate with oracle wallet manager and orapki utilities
Uploading certificate with oracle wallet manager and orapki utilities
 
Creating new service name for oracle database
Creating new service name for oracle databaseCreating new service name for oracle database
Creating new service name for oracle database
 
İleri Seviye T-SQL Programlama - Chapter 09
İleri Seviye T-SQL Programlama - Chapter 09İleri Seviye T-SQL Programlama - Chapter 09
İleri Seviye T-SQL Programlama - Chapter 09
 
Hyperion 11-1-2-3-installation-guide-on-linux
Hyperion 11-1-2-3-installation-guide-on-linuxHyperion 11-1-2-3-installation-guide-on-linux
Hyperion 11-1-2-3-installation-guide-on-linux
 
İleri Seviye T-SQL Programlama - Chapter 05
İleri Seviye T-SQL Programlama - Chapter 05İleri Seviye T-SQL Programlama - Chapter 05
İleri Seviye T-SQL Programlama - Chapter 05
 
İleri Seviye T-SQL Programlama - Chapter 16
İleri Seviye T-SQL Programlama - Chapter 16İleri Seviye T-SQL Programlama - Chapter 16
İleri Seviye T-SQL Programlama - Chapter 16
 
phpMyAdmin con Xampp
phpMyAdmin con XamppphpMyAdmin con Xampp
phpMyAdmin con Xampp
 
SAP ABAP Latest Interview Questions with Answers by Garuda Trainings
SAP ABAP Latest Interview Questions with Answers by Garuda TrainingsSAP ABAP Latest Interview Questions with Answers by Garuda Trainings
SAP ABAP Latest Interview Questions with Answers by Garuda Trainings
 
Trigger and cursor program using sql
Trigger and cursor program using sqlTrigger and cursor program using sql
Trigger and cursor program using sql
 
İleri Seviye T-SQL Programlama - Chapter 12
İleri Seviye T-SQL Programlama - Chapter 12İleri Seviye T-SQL Programlama - Chapter 12
İleri Seviye T-SQL Programlama - Chapter 12
 
넥슨 글로벌 플랫폼 구축 이야기 : DB Migration case study (임현수 플랫폼인프라실 Technical Manager, 넥...
넥슨 글로벌 플랫폼 구축 이야기 : DB Migration case study (임현수 플랫폼인프라실 Technical Manager, 넥...넥슨 글로벌 플랫폼 구축 이야기 : DB Migration case study (임현수 플랫폼인프라실 Technical Manager, 넥...
넥슨 글로벌 플랫폼 구축 이야기 : DB Migration case study (임현수 플랫폼인프라실 Technical Manager, 넥...
 
09 Managing Dependencies
09 Managing Dependencies09 Managing Dependencies
09 Managing Dependencies
 

Último

Portafolio de servicios Centro de Educación Continua EPN
Portafolio de servicios Centro de Educación Continua EPNPortafolio de servicios Centro de Educación Continua EPN
Portafolio de servicios Centro de Educación Continua EPNjmorales40
 
CALENDARIZACION DEL MES DE JUNIO - JULIO 24
CALENDARIZACION DEL MES DE JUNIO - JULIO 24CALENDARIZACION DEL MES DE JUNIO - JULIO 24
CALENDARIZACION DEL MES DE JUNIO - JULIO 24auxsoporte
 
ensayo literario rios profundos jose maria ARGUEDAS
ensayo literario rios profundos jose maria ARGUEDASensayo literario rios profundos jose maria ARGUEDAS
ensayo literario rios profundos jose maria ARGUEDASAntoineMoltisanti
 
Material-de-Apoyo-Escuela-Sabatica-02-2-2024.pptx.ppt
Material-de-Apoyo-Escuela-Sabatica-02-2-2024.pptx.pptMaterial-de-Apoyo-Escuela-Sabatica-02-2-2024.pptx.ppt
Material-de-Apoyo-Escuela-Sabatica-02-2-2024.pptx.pptAntonioaraujo810405
 
PLAN DE TRABAJO CONCURSO NACIONAL CREA Y EMPRENDE.docx
PLAN DE TRABAJO CONCURSO NACIONAL CREA Y EMPRENDE.docxPLAN DE TRABAJO CONCURSO NACIONAL CREA Y EMPRENDE.docx
PLAN DE TRABAJO CONCURSO NACIONAL CREA Y EMPRENDE.docxDavidAlvarez758073
 
Evaluación de los Factores Internos de la Organización
Evaluación de los Factores Internos de la OrganizaciónEvaluación de los Factores Internos de la Organización
Evaluación de los Factores Internos de la OrganizaciónJonathanCovena1
 
Proceso de admisiones en escuelas infantiles de Pamplona
Proceso de admisiones en escuelas infantiles de PamplonaProceso de admisiones en escuelas infantiles de Pamplona
Proceso de admisiones en escuelas infantiles de PamplonaEdurne Navarro Bueno
 
Presentación Pedagoía medieval para exposición en clases
Presentación Pedagoía medieval para exposición en clasesPresentación Pedagoía medieval para exposición en clases
Presentación Pedagoía medieval para exposición en clasesGustavo Cano
 
corpus-christi-sesion-de-aprendizaje.pdf
corpus-christi-sesion-de-aprendizaje.pdfcorpus-christi-sesion-de-aprendizaje.pdf
corpus-christi-sesion-de-aprendizaje.pdfYolandaRodriguezChin
 
Presentación Propuesta de Proyecto Social Colorido y Juvenil Multicolor y Neg...
Presentación Propuesta de Proyecto Social Colorido y Juvenil Multicolor y Neg...Presentación Propuesta de Proyecto Social Colorido y Juvenil Multicolor y Neg...
Presentación Propuesta de Proyecto Social Colorido y Juvenil Multicolor y Neg...crcamora123
 
Proyecto integrador Vereda Cujacal Centro.pptx
Proyecto integrador Vereda Cujacal Centro.pptxProyecto integrador Vereda Cujacal Centro.pptx
Proyecto integrador Vereda Cujacal Centro.pptxvanessaavasquez212
 
ACERTIJO DE CARRERA OLÍMPICA DE SUMA DE LABERINTOS. Por JAVIER SOLIS NOYOLA
ACERTIJO DE CARRERA OLÍMPICA DE SUMA DE LABERINTOS. Por JAVIER SOLIS NOYOLAACERTIJO DE CARRERA OLÍMPICA DE SUMA DE LABERINTOS. Por JAVIER SOLIS NOYOLA
ACERTIJO DE CARRERA OLÍMPICA DE SUMA DE LABERINTOS. Por JAVIER SOLIS NOYOLAJAVIER SOLIS NOYOLA
 
Presentación de medicina Enfermedades Fotográfico Moderno Morado (1).pdf
Presentación de medicina Enfermedades Fotográfico Moderno Morado (1).pdfPresentación de medicina Enfermedades Fotográfico Moderno Morado (1).pdf
Presentación de medicina Enfermedades Fotográfico Moderno Morado (1).pdfjuancmendez1405
 
Ferias de ciencias y estrategia STEAM – PNFCyT 2024.pdf
Ferias de ciencias y estrategia STEAM – PNFCyT 2024.pdfFerias de ciencias y estrategia STEAM – PNFCyT 2024.pdf
Ferias de ciencias y estrategia STEAM – PNFCyT 2024.pdfJudithRomero51
 
Módulo No. 1 Salud mental y escucha activa FINAL 25ABR2024 técnicos.pptx
Módulo No. 1 Salud mental y escucha activa FINAL 25ABR2024 técnicos.pptxMódulo No. 1 Salud mental y escucha activa FINAL 25ABR2024 técnicos.pptx
Módulo No. 1 Salud mental y escucha activa FINAL 25ABR2024 técnicos.pptxPabloPazmio14
 
Fase 1, Lenguaje algebraico y pensamiento funcional
Fase 1, Lenguaje algebraico y pensamiento funcionalFase 1, Lenguaje algebraico y pensamiento funcional
Fase 1, Lenguaje algebraico y pensamiento funcionalYasneidyGonzalez
 

Último (20)

Portafolio de servicios Centro de Educación Continua EPN
Portafolio de servicios Centro de Educación Continua EPNPortafolio de servicios Centro de Educación Continua EPN
Portafolio de servicios Centro de Educación Continua EPN
 
PPT: El fundamento del gobierno de Dios.
PPT: El fundamento del gobierno de Dios.PPT: El fundamento del gobierno de Dios.
PPT: El fundamento del gobierno de Dios.
 
CALENDARIZACION DEL MES DE JUNIO - JULIO 24
CALENDARIZACION DEL MES DE JUNIO - JULIO 24CALENDARIZACION DEL MES DE JUNIO - JULIO 24
CALENDARIZACION DEL MES DE JUNIO - JULIO 24
 
ensayo literario rios profundos jose maria ARGUEDAS
ensayo literario rios profundos jose maria ARGUEDASensayo literario rios profundos jose maria ARGUEDAS
ensayo literario rios profundos jose maria ARGUEDAS
 
Material-de-Apoyo-Escuela-Sabatica-02-2-2024.pptx.ppt
Material-de-Apoyo-Escuela-Sabatica-02-2-2024.pptx.pptMaterial-de-Apoyo-Escuela-Sabatica-02-2-2024.pptx.ppt
Material-de-Apoyo-Escuela-Sabatica-02-2-2024.pptx.ppt
 
PLAN DE TRABAJO CONCURSO NACIONAL CREA Y EMPRENDE.docx
PLAN DE TRABAJO CONCURSO NACIONAL CREA Y EMPRENDE.docxPLAN DE TRABAJO CONCURSO NACIONAL CREA Y EMPRENDE.docx
PLAN DE TRABAJO CONCURSO NACIONAL CREA Y EMPRENDE.docx
 
Evaluación de los Factores Internos de la Organización
Evaluación de los Factores Internos de la OrganizaciónEvaluación de los Factores Internos de la Organización
Evaluación de los Factores Internos de la Organización
 
6.Deícticos Dos_Enfermería_EspanolAcademico
6.Deícticos Dos_Enfermería_EspanolAcademico6.Deícticos Dos_Enfermería_EspanolAcademico
6.Deícticos Dos_Enfermería_EspanolAcademico
 
Proceso de admisiones en escuelas infantiles de Pamplona
Proceso de admisiones en escuelas infantiles de PamplonaProceso de admisiones en escuelas infantiles de Pamplona
Proceso de admisiones en escuelas infantiles de Pamplona
 
Presentación Pedagoía medieval para exposición en clases
Presentación Pedagoía medieval para exposición en clasesPresentación Pedagoía medieval para exposición en clases
Presentación Pedagoía medieval para exposición en clases
 
corpus-christi-sesion-de-aprendizaje.pdf
corpus-christi-sesion-de-aprendizaje.pdfcorpus-christi-sesion-de-aprendizaje.pdf
corpus-christi-sesion-de-aprendizaje.pdf
 
Presentación Propuesta de Proyecto Social Colorido y Juvenil Multicolor y Neg...
Presentación Propuesta de Proyecto Social Colorido y Juvenil Multicolor y Neg...Presentación Propuesta de Proyecto Social Colorido y Juvenil Multicolor y Neg...
Presentación Propuesta de Proyecto Social Colorido y Juvenil Multicolor y Neg...
 
Power Point: Luz desde el santuario.pptx
Power Point: Luz desde el santuario.pptxPower Point: Luz desde el santuario.pptx
Power Point: Luz desde el santuario.pptx
 
Proyecto integrador Vereda Cujacal Centro.pptx
Proyecto integrador Vereda Cujacal Centro.pptxProyecto integrador Vereda Cujacal Centro.pptx
Proyecto integrador Vereda Cujacal Centro.pptx
 
3.Conectores uno_Enfermería_EspAcademico
3.Conectores uno_Enfermería_EspAcademico3.Conectores uno_Enfermería_EspAcademico
3.Conectores uno_Enfermería_EspAcademico
 
ACERTIJO DE CARRERA OLÍMPICA DE SUMA DE LABERINTOS. Por JAVIER SOLIS NOYOLA
ACERTIJO DE CARRERA OLÍMPICA DE SUMA DE LABERINTOS. Por JAVIER SOLIS NOYOLAACERTIJO DE CARRERA OLÍMPICA DE SUMA DE LABERINTOS. Por JAVIER SOLIS NOYOLA
ACERTIJO DE CARRERA OLÍMPICA DE SUMA DE LABERINTOS. Por JAVIER SOLIS NOYOLA
 
Presentación de medicina Enfermedades Fotográfico Moderno Morado (1).pdf
Presentación de medicina Enfermedades Fotográfico Moderno Morado (1).pdfPresentación de medicina Enfermedades Fotográfico Moderno Morado (1).pdf
Presentación de medicina Enfermedades Fotográfico Moderno Morado (1).pdf
 
Ferias de ciencias y estrategia STEAM – PNFCyT 2024.pdf
Ferias de ciencias y estrategia STEAM – PNFCyT 2024.pdfFerias de ciencias y estrategia STEAM – PNFCyT 2024.pdf
Ferias de ciencias y estrategia STEAM – PNFCyT 2024.pdf
 
Módulo No. 1 Salud mental y escucha activa FINAL 25ABR2024 técnicos.pptx
Módulo No. 1 Salud mental y escucha activa FINAL 25ABR2024 técnicos.pptxMódulo No. 1 Salud mental y escucha activa FINAL 25ABR2024 técnicos.pptx
Módulo No. 1 Salud mental y escucha activa FINAL 25ABR2024 técnicos.pptx
 
Fase 1, Lenguaje algebraico y pensamiento funcional
Fase 1, Lenguaje algebraico y pensamiento funcionalFase 1, Lenguaje algebraico y pensamiento funcional
Fase 1, Lenguaje algebraico y pensamiento funcional
 

Ejercicios

  • 2. 1. Pide la edad y si es mayor de 18 años indica que ya puede conducir.
  • 3. <script> //PIDE POR TECLADO LA EDAD var edad = prompt("Introduce tu edad"); //COMPRUEBA QUE LO INTRODUCIDO ES UN NÚMERO if (Number(edad) == edad) { //SI ES MAYOR DE 18 if (edad > 18) { //IMPRIME EN PANTALLA EL MENSAJE document.write("Puedes conducir"); } } //SINÓ else { //MUESTRA UN MENSAJE alert("Introduce un numero válido"); } </script>
  • 4. 2. Pide una nota (número). Muestra la calificación según la nota: 0-3: Muy deficiente 3-5: Insuficiente 5-6: Suficiente 6-7: Bien 7-9: Notable 9-10: Sobresaliente
  • 5. <script> //BUCLE PARA QUE PERMITA INTRODUCIR MÁS DE UNA NOTA do { //PIDE UNA NOTA POR TECLADO Y LA GUARDA EN LA VARIABLE nota var nota = prompt("Introduce tu nota"); //SI SE INTRODUJO UN NÚMERO if (Number(nota) == nota) { //SI LA NOTA ES ENTRE 0 Y 10 COMPRUEBA EL RANGO Y DA UN MENSAJE if (nota > 0 && nota <= 10) { if (nota < 3) { alert("Muy deficiente"); } else if (nota < 5) { alert("Insuficiete"); } else if (nota < 6) { alert("Suficiente"); } else if (nota < 7) { alert("Bien"); } else if (nota < 9) { alert("Notable"); 5 } else if (nota >= 9) { alert("Sobresaliente"); } } //SI LA NOTA NO ES ENTRE 0 Y 10 else { alert("Nota erronea"); } } //SI LA NOTA INTRODUCIDA NO ES UN NÚMERO else { //SI SE HA PULSADO ACEPTAR SIN INTRODUCIR NADA if (nota != undefined) { //No es Undefined cuando se pulsa aceptar. alert("Introduce un numero valido"); } } //EL BUCLE VUELVE ARRIBA MIENTRAS NO SE HAYA PULSADO CANCELAR } while (nota != undefined); //Undefined es cuando se pulsa Cancelar. </script>
  • 6. 3. Realiza un script que pida cadenas de texto hasta que se pulse “cancelar”. Al salir con “cancelar” deben mostrarse todas las cadenas concatenadas con un guión -.
  • 7. <script> //DECLARAMOS UNA VARIABLE DONDE VAMOS A CONCATENAR LAS CADENAS var resultado = ""; //BUCLE DO WHILE PARA INTRODUCIR VARIAS CADENAS do { //PEDIMOS LA CADENA POR TECLADO var cadena = prompt("Introduce una cadena"); //SI LA VARIABLE RESULTADO ESTÁ VACÍA if (resultado == "") { //CONCATENAMOS SIN UTILIZAR GUIÓN resultado = resultado + cadena; } //SINÓ else { //CONCATENAMOS CON GUIÓN resultado = resultado + "-" + cadena; } //MIENTRAS SE PULSE ACEPTAR EN EL MENSAJE EMERGENTE CONFIRM } while (confirm("Desea seguir?")); //SI SE PULSÓ CANCELAR IMPRIMIMOS EL RESULTADO document.write(resultado); </script>