-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoop.html
36 lines (33 loc) · 877 Bytes
/
oop.html
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
<html>
<head></head>
<body>
<script>
var usuario = function(nombre,mail){
this.nombre = nombre;
this.email = mail;
this.puntos =[];
}
usuario.prototype = {
constructor: usuario,
salvarPuntos: function(puntos){
this.puntos.push(puntos);
},
mostrarNombrePuntos:function(){
var todosPuntos = this.puntos.length > 0 ? this.puntos.join(',') : 'No hay puntos aun';
return this.name + todosPuntos;
},
cambiarEmail:function(newEmail){
this.email = newEmail;
}
}
/*usuario.prototype.constructor = usuario;
usuario.prototype.salvarPuntos = function(puntos){
this.puntos.push(puntos);
}*/
var usuario1 = new usuario ("Alvaro","[email protected]");
usuario1.salvarPuntos(10);
usuario1.mostrarNombrePuntos(10);
usuario1.cambiarEmail("[email protected]");
</script>
</body>
</html>