Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var oportnum=5;
- var pregunta = prompt("Dame un numero del 1 al 9");
- var contador;
- var resultado = pregunta * contador;
- var contadorx =5;
- while(contadorx > 0){
- if(isNaN(pregunta) === true){ //Quiere decir que es un string
- oportnum--;
- alert("No es un numero, te quedan" + oportnum + " oportnunidades, introduce un numero");
- if(oportnum > 0){
- var pregunta = prompt("Dame un numero del 1 al 9");
- }else{
- alert("Demasiados errores");
- }
- }
- if(pregunta < 1 || pregunta > 9){
- oportnum--;
- alert("Es un numero pero no esta entre el 1 y el 9, te quedan" + oportnum + " oportnunidades, introduce un numero");
- if(oportnum > 0){
- var pregunta = prompt("Dame un numero del 1 al 9");
- }else{
- alert("Demasiados errores");
- }
- }else{
- while(pregunta>0) {
- alert("he entrado");
- document.write(" La tabla del " + pregunta + " es </br>");
- for(var contador = 1; contador <= 10; contador++) {
- var resultado = pregunta * contador;
- document.write(pregunta + "x" +contador + "=" + resultado + "</br>");
- }
- document.write("</br>");
- pregunta--;
- contador=1;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement