-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path06-condicionales.js
More file actions
69 lines (55 loc) · 1.28 KB
/
06-condicionales.js
File metadata and controls
69 lines (55 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
'use strict'
// CONDICIONAL "IF"
// ES UNA ESTRUCTURA DE CONTROL QUE PERMITE COMPARAR ALGO
// SI A es igial a B entonces haz algo
var edad=90;
var nombre = 'David Suarez';
/*
operadores relacionales
Mayor: >
Menor: <
MAyor o igual: >=
Menor o igual: <=
Igual: ==
Distinto: !=
*/
if (edad>=18){
// Es mayor de edad
console.log(nombre+' '+"tiene"+' '+edad+' '+ "años, es mayor de edad");
if(edad<=33){
console.log('Todavia eres millenial');
}else if (edad>=70) {
console.log("Eres anciano");
}else{
console.log("Ya no eres millenial");
}
}else{
console.log(nombre+' '+"tiene"+' '+edad+' '+ "años, es menor de edad");
}
/*}else{
console.log("Ya no eres millenial");
}*/
/* OPERADORES LOGICOS
Son
AND (Y): &&
OR (O): ||
NEGACIÓN: !
*/
//NEGACIÖN
//var year =2028; SI CUMPLE Y MUESTRA que "termina en 8"
if (year != 2016){
console.log("El año no es 2016, realemnte es: "+' '+year);
}
// AND
if (year >= 2000 && year <= 2020 && year != 2018){
console.log("Estamos en la era actual");
}else {
console.log("Estamos en la era post moderna");
}
// OR
// SE UTILIZAN LOS PARENTESIS "()" PARA DAR "MAYOR PREORIDAD A CIERTA OPERACIÓN"
if (year == 2008 || (year >= 2018 && year == 2028)){
console.log("El año termina en 8");
}else{
console.log("Año no registrado");
}