Skip to content

Instantly share code, notes, and snippets.

// the competitor is the atomic entity of a tournament
var Competitor = Backbone.Model.extend({
defaults: {
firstname: "Bye",
lastname: "",
team: "None",
id: Math.floor(Math.random() * 10000)
}
})
{name:'griff'}
// string input is assumed, punctuation is ignored, and the earliest word wins a tie
function getLongestWord (sentance) {
var words = sentance.split(/[\s-]+/);
words = words.map( function(word) {return word.match(/[\w\d]+/)[0] || '';} );
return words.reduce( function(a,b) {return (a.length >= b.length)? a:b;} );
}