Skip to content

Commit 817eb1c

Browse files
authored
Merge pull request mouredev#3638 from Ocram1304/main
#10-JavaScript
2 parents cb83c7f + 4a13431 commit 817eb1c

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
function dividir(num1,num2){
2+
3+
if(num2 === 0){
4+
throw new Error("No se puede dividir entre cero");
5+
}
6+
else{
7+
return num1/num2;
8+
}
9+
10+
}
11+
function Probar(n1,n2){
12+
try {
13+
dividir(n1,n2);
14+
15+
} catch (error) {
16+
console.log("Erro:",error);
17+
}
18+
finally{
19+
console.log("Intente ingrsar un divisor distinto a 0");
20+
}
21+
}
22+
Probar(10,0);
23+
//Difucultad Extra
24+
25+
function exepciones(us,pas){
26+
if(pas.length<7){
27+
throw new Error ("La contraseña debe de tener más de 7 caracteres");
28+
}
29+
else if(typeof us !== 'string'){
30+
throw new Error("Solo se permiten caracteres");
31+
}
32+
else if(us === "" || pas === ""){
33+
throw new Error ("Campos vacios");
34+
}
35+
36+
}
37+
function Comprobar(user, password){
38+
try {
39+
exepciones(user,password);
40+
console.log("No ocurrienron exepciones",user,password);
41+
42+
} catch (error) {
43+
confirm.log ("Error", error);
44+
}
45+
finally{
46+
47+
console.log("Ingrese los datos nuevamente");
48+
}
49+
50+
51+
}

0 commit comments

Comments
 (0)