Skip to content

Instantly share code, notes, and snippets.

@glauberramos
Created July 11, 2012 02:24
Show Gist options
  • Save glauberramos/3087548 to your computer and use it in GitHub Desktop.
Save glauberramos/3087548 to your computer and use it in GitHub Desktop.
Bad javascript code - Example for blog post
//this function represents a book from an online library
//it has 3 methods to search the book, remove a specific word and change it
//it has 4 attributes, name, author, date and content
//creates libaries stuffz
function elementliBRaryContent(a,b,c,d) {
var bnam = a;var baut = b;
var bdat = c;
var bcont = d;
var self = { findword: function(x) { return bcont.indexOf(x)>=0;},
findremword: function(y) { return bcont.indexOf(y)>=0?bcont.replace(y + ' ',''):bcont;},
findrepword: function(z,w) { return bcont.indexOf(z)>=0?bcont.replace(z,w):bcont;},
getbnam: function() {return bnam;},
getbaut: function() {return baut;},
getbdat: function() {return bdat;},
getbcont: function() {return bcont;}
};
return self;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment