Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- function Person(firstName, lastName, age) {
- this.firstName = firstName;
- this.lastName = lastName;
- this.age = age;
- Person.prototype.fullData = function(){
- return firstName + lastName + "\(age " + age +"\)";
- };
- }
- var people = [
- new Person("Scott", "Guthrie", 38),
- new Person("Scott", "Johns", 36),
- new Person("Scott", "Hanselman", 39),
- new Person("Jesse", "Liberty", 57),
- new Person("Jon", "Skeet", 38)
- ];
- var criteria = "age";
- var matchArr = {};
- for (var i = 0; i < people.length; i++){
- var key = "Group " + people[i][criteria].toString();
- matchArr[key] = people[i].firstName + " " + people[i].lastName + "(age " + people[i].age + ")";
- }
- console.log(matchArr);
- </script>
Advertisement
Add Comment
Please, Sign In to add comment