<commit_before>//Hold family members
var familyTree = [];

function Person(name)
{
	this.name = name;
	this.parent = null;
	this.children = [];
	this.siblings = [];
	this.grandparent = null;
	
	this.addChild = function(name) {
		var child = new Person(name);
		child.parent = this;
			if (child.parent.parent != null) {
				child.grandparent = child.parent.parent;
			}
		this.children.push(child);
	};
	this.init();
};

//Add new people to family tree
Person.prototype.init = function(){
	familyTree.push(this)
};

var findPerson = function(name){
	for (var i = 0; i < familyTree.length; i++) {
		if (familyTree[i].name === name){
//			console.log(familyTree[i]);
			return familyTree[i];
		}
	}
	console.log("Person not found");
}

//Add family members
var nancy = new Person("Nancy");
nancy.addChild("Adam")
nancy.addChild("Jill")
nancy.addChild("Carl")
findPerson("Carl").addChild("Joseph")
findPerson("Carl").addChild("Catherine")
findPerson("Jill").addChild("Kevin")
findPerson("Kevin").addChild("Samuel")
findPerson("Kevin").addChild("George")
findPerson("Kevin").addChild("James")
findPerson("Kevin").addChild("Aaron")
findPerson("James").addChild("Mary")
findPerson("George").addChild("Patrick")
findPerson("George").addChild("Robert")


console.log(findPerson("James").grandparent)<commit_msg>Add highestGrandchildren and noChildren functions and update Person prototype attributes<commit_after>//Hold family members
var familyTree = [];

function Person(name)
{
	this.name = name;
	this.parent = null;
	this.children = [];
	this.siblings = [];
	this.grandparent = null;
	this.grandchildren = 0;
	
	this.addChild = function(name) {
		var child = new Person(name);
		child.parent = this;
			if (child.parent.parent != null) {
				var granny = child.parent.parent
				child.grandparent = granny.name;
				granny.grandchildren += 1;
			}
		this.children.push(child);
	};
	//Auto add to family tree
	this.init();
};

//Add new people to family tree
Person.prototype.init = function(){
	familyTree.push(this)
};

var findPerson = function(name){
	for (var i = 0; i < familyTree.length; i++) {
		if (familyTree[i].name === name){
			return familyTree[i];
		}
	}
	console.log("Person not found");
}

var noChildren = function(){
	for (var i = 0; i < familyTree.length; i++) {
		if (familyTree[i].children.length === 0){
			console.log(familyTree[i].name);
		}
	}
}

var highestGrandchildren = function(){
	var highest = familyTree[0];
	for (var i = 0; i < familyTree.length-1; i++) {
		if (familyTree[i].grandchildren > highest.grandchildren){
			highest = familyTree[i]
		}
	}
	console.log(highest.name);
}

//Add family members
var nancy = new Person("Nancy");
nancy.addChild("Adam")
nancy.addChild("Jill")
nancy.addChild("Carl")
findPerson("Carl").addChild("Joseph")
findPerson("Carl").addChild("Catherine")
findPerson("Jill").addChild("Kevin")
findPerson("Kevin").addChild("Samuel")
findPerson("Kevin").addChild("George")
findPerson("Kevin").addChild("James")
findPerson("Kevin").addChild("Aaron")
findPerson("James").addChild("Mary")
findPerson("George").addChild("Patrick")
findPerson("George").addChild("Robert")


console.log(findPerson("Kevin").grandchildren)
noChildren();
highestGrandchildren();
{'fraction_non_alphanumeric': 0.1785602991586164, 'fraction_numerical': 0.0028046120286693674, 'mean_word_length': 5.184971098265896, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '147359', 'n_tokens_mistral': 1164, 'n_tokens_neox': 1053, 'n_words': 212}