Created
October 26, 2011 02:17
-
-
Save nmelox/1315215 to your computer and use it in GitHub Desktop.
segundo_javascript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function valorAuto (valor,modelo,año){ | |
if (typeof(valor) != "number" || valor < 0) { | |
console.error ("Ingrese un numero como primer parametro"); | |
return; | |
} | |
if (typeof(modelo) != "string" || modelo.lenght <= 0) { | |
console.error ("Ingrese un texto como segundo parametro"); | |
return; | |
} | |
if (typeof(año) != "number" || valor < 0) { | |
console.error ("Ingrese un numero como tercer parametro"); | |
return; | |
} | |
if (año > 2011 || año < 1900){ | |
console.error ("Ingrese un año valido"); | |
return; | |
} | |
console.log (modelo); | |
if ( modelo != "Fiesta" || modelo != "Falcon"){ | |
console.log (modelo); | |
console.error ("La empresa no trabaja con ese modelo"); | |
return; | |
} | |
if (año < 1970){ | |
valor = valor * 0,5; | |
} | |
else if ( año >= 1970 && año <= 1990){ | |
valor = valor * 0,25; | |
} | |
else if ( año > 1990){ | |
valor = valor * 0,1; | |
} | |
console.log ("El valor de su auto modelo "+ modelo +" es de"+ valor); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hay errores en el calculo de años. Proba pensando que siempre te va a venir un año de 4 cifras