forked from Natyushk/DEV014-dataverse-chat
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.js
More file actions
28 lines (24 loc) · 728 Bytes
/
example.js
File metadata and controls
28 lines (24 loc) · 728 Bytes
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
const dias =(nombre)=>`Buenos dias ${nombre} `
const tardes = (nombre)=>`Buenas tardes ${nombre} `
const saludar=(nombrePersona, unBenditoCallback)=>{
const construirSaludo = unBenditoCallback(nombrePersona)
return construirSaludo+ ' que tengas buen dia';
}
/*
console.log(saludar('nataly molano', tardes));
console.log(saludar('carlos', dias));
console.log(saludar('Sandy', (lapersona)=>`Buenas nochesss ${lapersona}`));
*/
const comer=(time)=>new Promise((res, rej)=>{
if(time<12){
res(saludar('nataly', tardes))
}else if(time>12 && time<24){
res(saludar('Carlos', tardes))
}
rej('Error hora invalida')
})
comer(26).then(respuesta=>{
console.log(respuesta);
}).catch(err=>{
console.error(err);
})