Skip to content

Instantly share code, notes, and snippets.

@dustinc
Created October 2, 2012 23:09
Show Gist options
  • Save dustinc/3823882 to your computer and use it in GitHub Desktop.
Save dustinc/3823882 to your computer and use it in GitHub Desktop.
Teacher.virtual('highest_degree').get(function() {
if(this.education.degrees.length > 1) {
for(var i=0; i < this.education.degrees.length; i++) {
switch(this.education.degrees[i]) {
case 'Doctorates':
this.education.degrees[i].weight = 100;
break;
case 'Masters':
this.education.degrees[i].weight = 10;
break;
case 'Bachelors':
this.education.degrees[i].weight = 1;
break;
}
}
this.education.degrees.sort(function(a, b) {
if(a.weight < b.weight) {
return 1;
} else {
return -1;
}
});
}
return this.education.degrees[0].degree_type;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment