-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustomObjects.js
More file actions
56 lines (43 loc) · 1.18 KB
/
customObjects.js
File metadata and controls
56 lines (43 loc) · 1.18 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
// function makePerson(first,last){
// return {
// first:first,
// last:last
// };
// }
// console.log(makePerson("amith","sai"));
// function personFullName(person){
// return person.first+' '+person.last;
// }
// console.log(personFullName(makePerson("amith","sai")));
// function personNameRev(person){
// return person.last+' '+person.first;
// }
// console.log(personNamerev(makePerson("amith","sai")));
function Person(first,last){
this.last=last;
this.first=first;
// this.fullName = function(){
// return first+' '+last;
// };
// this.fullNameRev=function(){
// return last + ' '+first;
// };
}
var s=new Person('amith','sai');
// console.log(s.fullName());
// console.log(s.fullNameRev());
Person.prototype.fullName =()=>this.first +' '+this.last;
Person.prototype.fullNameRev =()=>this.last+' '+this.first;
Person.prototype.firstNameCaps =function(){
return this.first.toUpperCase();
};
String.prototype.rev=function(){
var r='';
for(let i=this.length-1;i>=0;i--){
r+=this[i];
}
return r;
};
console.log(s.fullName());
console.log(s.firstNameCaps());
console.log(s.fullName().rev());