<commit_before> // JavaScript Olympics

// I paired with: <NAME> on this challenge.

// This challenge took me [1] hours.



// Bulk Up

var sarah = {
	name: "<NAME>",
	event: "L<NAME>",
};

var addWin = function(athletes) {
	for (i in athletes) {
		athletes[i] = athletes[i].name + " won the " + athletes[i].event + "!";
	}
	console.log(athletes[i]);
	};

addWin([sarah])


// Jumble your words

var jumble = function(string) {
	console.log(string.split("").reverse().join(""));
}

jumble("This is a string!")


// 2,4,6,8

var even = function(array) {
	for (var i = 0; i < array.length; i ++) {
		if (array[i] % 2 === 0) {
			console.log(array[i]);	
		}
	}
}

even([1,2,3,4,5,6,7,8,9])

// "We built this city"

var Athlete = function(name, age, sport, quote) {
	this.name = name;
	this.age = age;
	this.sport = sport;
	this.quote = quote;
}

var michaelPhelps = new Athlete("<NAME>", 29, "swimming", "It's medicinal I swear!")
console.log(michaelPhelps.constructor === Athlete)
console.log(michaelPhelps.name + " " + michaelPhelps.sport + " " + michaelPhelps.quote)


// Reflection

/*

1. What JavaScript knowledge did you solidify in this challenge?

I solidified the my understanding of the JavaScript syntax in this challenge. By encountering errors for simple syntax mistakes in this challenge, I was able to learn where I need to place "{}" and ";" in my code. Another concept that I solidified was creating JavaScript objects and calling on them in an array. The first released helped me reflect on my reading and implement it into a piece of code. One final component that I gained a better understanding on was the concept of a constructor function. I wasn't that comfortable with the concept after reading Eloquent JavaScript but actually putting it to use helped me gain more knowledge on how to actually implement it.

2. What are constructor functions?

A constructor function is any function that is used as a constructor. A function can be written to be used as a constructor or to be called as a normal function. A constructor is used with the new keyword. When a constructor is called, JavaScript creates a new object and sets the constructor property to that specified for the object. A constructor is useful when you want to create multiple similar objects with the same properties and methods. Constructors are like classes in Ruby.

3. How are constructors different from Ruby classes (in your research)?

The difference is in the type of objects and interactions involved in Ruby and JavaScript. Ruby uses objects inherited from Class to create new objects, whereas JavaScript can either define literal objects or constructor functions to create new objects.
JavaScript also allows for the creation of new objects with "Function.prototype", the idea that new objects reference the prototype object of the constructor function, thus inheriting its behavior. In Ruby, this is done through class objects and method definitions.

*/<commit_msg>Complete Challenge 7.6 for Practice<commit_after>// JavaScript Olympics

// I paired with: <NAME> on this challenge.

// This challenge took me [1] hours.



// Bulk Up

var tomBrady = {name: "<NAME>", event: "Super Bowl"};
var kobeBryant = {name: "<NAME>", event: "NBA Finals"};

athleteArray = [];
athleteArray.push(tomBrady, kobeBryant);
console.log(athleteArray);

function winner(array_of_athletes) {
	for(i=0;i < array_of_athletes.length; i++) {
		array_of_athletes[i].win = array_of_athletes[i].name + " won the " + array_of_athletes[i].event;
	}
	return array_of_athletes
}

console.log(winner(athleteArray))

// Jumble your words

function reverseString(string) {
	var revString = string.split("").reverse().join("");
	return revString;
}

console.log(reverseString("<NAME>"));

// 2,4,6,8
// Attempt 1

var even = function(array) {
	evenArray = []
	for (var i = 0; i < array.length; i ++) {
		if (array[i] % 2 === 0) {
			 evenArray.push(array[i]);	
		}
	}
	return evenArray
}

console.log(even([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]))

// Attempt 2
function even(array_of_integers) {
	evenArray = [];
	for (i=0; i < array_of_integers.length; i++) {
		num = array_of_integers[i] % 2
		if (num == 0) {
			evenArray.push(array_of_integers[i]);
		} 
	}
	return evenArray;
}

console.log(even([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]))

// "We built this city"

var Athlete = function(name, age, sport, quote) {
	this.name = name;
	this.age = age;
	this.sport = sport;
	this.quote = quote;
}

var michaelPhelps = new Athlete("<NAME>", 29, "swimming", "It's medicinal I swear!")
console.log(michaelPhelps.constructor === Athlete)
console.log(michaelPhelps.name + " " + michaelPhelps.sport + " " + michaelPhelps.quote)


// Reflection

/**

1. What JavaScript knowledge did you solidify in this challenge?

I solidified the my understanding of the JavaScript syntax in this challenge. By encountering errors for simple syntax mistakes in this challenge, I was able to learn where I need to place "{}" and ";" in my code. Another concept that I solidified was creating JavaScript objects and calling on them in an array. The first released helped me reflect on my reading and implement it into a piece of code. One final component that I gained a better understanding on was the concept of a constructor function. I wasn't that comfortable with the concept after reading Eloquent JavaScript but actually putting it to use helped me gain more knowledge on how to actually implement it.

2. What are constructor functions?

A constructor function is any function that is used as a constructor. A function can be written to be used as a constructor or to be called as a normal function. A constructor is used with the new keyword. When a constructor is called, JavaScript creates a new object and sets the constructor property to that specified for the object. A constructor is useful when you want to create multiple similar objects with the same properties and methods. Constructors are like classes in Ruby.

3. How are constructors different from Ruby classes (in your research)?

The difference is in the type of objects and interactions involved in Ruby and JavaScript. Ruby uses objects inherited from Class to create new objects, whereas JavaScript can either define literal objects or constructor functions to create new objects.
JavaScript also allows for the creation of new objects with "Function.prototype", the idea that new objects reference the prototype object of the constructor function, thus inheriting its behavior. In Ruby, this is done through class objects and method definitions.

**/
{'fraction_non_alphanumeric': 0.0946969696969697, 'fraction_numerical': 0.015909090909090907, 'mean_word_length': 4.384176182707994, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 12, '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': '98848', 'n_tokens_mistral': 1966, 'n_tokens_neox': 1869, 'n_words': 844}