-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodulo2.js
More file actions
25 lines (24 loc) · 731 Bytes
/
Copy pathmodulo2.js
File metadata and controls
25 lines (24 loc) · 731 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
function agenda (titulo, inic) {
var _titulo = titulo;
var _contenido = inic;
return {
titulo: function() { return _titulo; },
meter: function(nombre, tf) { _contenido[nombre]=tf; },
tf: function(nombre) { return _contenido[nombre]; },
borrar: function(nombre) { delete _contenido[nombre]; },
toJSON: function() { return JSON.stringify(_contenido);},
listar: function() {
for (var nombre in _contenido) {
if(_contenido.hasOwnProperty(nombre)) {
console.log(nombre + ", " + _contenido[nombre] +" \n");
}
}
}
}
}
var amigos = agenda ("Amigos",
{ Pepe: 113278561,
José: 157845123,
Jesús: 178512355
});
amigos.listar();