xxxxxxxxxx
50
// Characters
let gair = ["Gair", "0", "Earth", "Compass World", "Fall", "Male", "M Nay", "Leader", "Games"];
let pubby = ["Pubby", "Ragger", "Dark", "Compass World", "Fall", "Male", "M Nay", "Animals", "Guns"];
let sarah = ["Sarah", "0", "Mind", "Party Sanctuary World", "Fall", "Female", "M Nay", "Demon", "Introverted"];
let scott = ["Scott", "Ragger", "Dark", "Compass World", "Summer", "Male", "S Nay", "Guns", "Sports"]; // Temporarily S Nay for testing
// Arrays
let last = [gair[1],pubby[1],sarah[1],scott[1]]
let type = [gair[2],pubby[2],sarah[2],scott[2]]
let world = [gair[3],pubby[3],sarah[3],scott[3]]
let birthday = [gair[4],pubby[4],sarah[4],scott[4]]
let gender = [gair[5],pubby[5],sarah[5],scott[5]]
let trait1 = [gair[6],pubby[6],sarah[6],scott[6]]
let trait2 = [gair[7],pubby[7],sarah[7],scott[7]]
let trait3 = [gair[8],pubby[8],sarah[8],scott[8]]
let traits = trait1.concat(trait2,trait3);
// Most Frequent
let counts = {};
let freq;
function mostFrequent(array){
for(var i = 0, len = array.length; i < len; i++){
var compare = 0;
var word = array[i];
if (word !== "0") {
if (counts[word] === undefined){
counts[word] = 1;
//console.log("undefined " + word);
} else {
counts[word] = counts[word] + 1;
//console.log("defined " + word);
}
if (counts[word] > compare){
compare = counts[word];
freq = array[i];
}
}
else {
console.log("Value was " + word)
}
}
return freq;
}
//console.log("Most: " + mostFrequent(type))
let printMost = [0, mostFrequent(last), mostFrequent(type), mostFrequent(world), mostFrequent(birthday), mostFrequent(gender), mostFrequent(traits)];
console.log(" :TEST: printMost: " + printMost);