Last active
July 30, 2018 10:49
-
-
Save PatrickKyei/0b46894e378e1f25bba24763a64aa22d to your computer and use it in GitHub Desktop.
JS Bin// source https://jsbin.com/joviqok
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script> | |
var People= { | |
Persons: ['John', 'Bob'], | |
displayPersons: function(){ | |
console.log(this.Persons.toString()); | |
}, | |
addFirstPerson: function(name){ | |
this.Persons.unshift(name); | |
this.displayPersons(); | |
}, | |
removeFirstPerson: function(){ | |
this.Persons.shift(); | |
this.displayPersons(); | |
}, | |
removeLastPerson: function(){ | |
this.Persons.pop(); | |
this.displayPersons(); | |
}, | |
addLastPerson: function(name){ | |
this.Persons.push(name); | |
this.displayPersons(); | |
}, | |
addSpecificPerson: function(position,name){ | |
this.Persons.splice(position,0,name); | |
this.displayPersons(); | |
}, | |
removeSpecificPerson: function(position,remove){ | |
this.Persons.splice(position,remove); | |
this.displayPersons(); | |
}, | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment