Win A Copy Of JavaScript Enlightenment By Cody Lindley
A few weeks ago, I blogged about Cody Lindley's new book, JavaScript Enlightenment. Like his previous book - jQuery Enlightenment - Lindley's new book makes use of technical thin-slicing - preferring simple code samples over prose when it comes to exploring the JavaScript language. This keeps the book brief and enjoyable while still acting as a highly effective learning medium.
Luckily, Cody has given me three copies of his book to give away for free! And, since JavaScript Enlightenment is all about mastering the JavaScript "Object", I thought I would try to keep the contest object-centric.
In order to enter, you must leave a comment below!
But, it's not quite that simple! On Friday at 3PM EST, I'm going to pick the winners from the "valid" comments. And, what is a "valid" comment, you ask? Well, for that, you'll have to look at the code below, which showcases just a few of the concepts that are explored, in-depth, in Cody Lindley's JavaScript Enlightenment.
<!DOCTYPE html>
<html>
<head>
<title>JavaScript Enlightenment By Cody Lindley</title>
</head>
<body>
<h1>
JavaScript Enlightenment By Cody Lindley
</h1>
<form>
<p>
Enter user's comment here:
</p>
<p>
<textarea name="comment" rows="10" cols="70"></textarea>
</p>
<p>
<button type="submit">Validate Comment</button>
</p>
</form>
<!-- Run scripts on DOM. -->
<script type="text/javascript" src="./jquery-1.6.1.js"></script>
<script type="text/javascript">
String.prototype.contains = function( substring ){
return( this.indexOf( substring) >= 0 );
};
function Comment( content ){
this.content = content.toLowerCase();
}
Comment.prototype.isValid = function(){
return( isFun.call( this.content ) );
};
Comment.prototype.toString = function(){
return( this.isValid() );
}
function isFun(){
return(
this.contains( "wicked" ) ||
this.contains( "hella" ) ||
this.contains( "crazy" ) ||
this.contains( "retarded" )
);
}
$( "form" ).submit(
function( event ){
var input = this.elements[ "comment" ];
alert( new Comment( input.value ) );
event.preventDefault();
}
);
</script>
</body>
</html>
Good luck! And remember, JavaScript is wicked awesome!
IMPORTANT UPDATE: It was properly brought to my attention that some of the code in this give-away would be too complicated for people who didn't already have a decent understanding of the JavaScript language. This makes total sense. As such, I've created this video in order to walk (as best I can) through the JavaScript features that this code is using:
I hope that helps!
Want to use code from this post? Check out the license.
Reader Comments
You, Sir, are hella wicked, and not AT ALL crazy like some retarded people may suggest.
Also, first comment.. woot!
This is a wicked idea!
This is hella wicked awesome! I hope I win, that'd be crazy retarded.
How do we know if the comment it's funny?! this idea it's crazy, and I may be retarded
This is a hella wicked crazy not so retarded comment!
I'd love a copy of that book!
wicked idea, bro
Wicked post Ben. I really want that book so bad its crazy!
I used to think that contests to win books are retarded, but I got enlightened.
The code is simple enought to understand, but just these few lines have enlightened me about the power of javascripts methods like call and apply combined with the ability to prototype everything open a new world of expérimentation that's not achievable by "traditional" languages. I would like to know more about it =)
This is crazy, I want a wicked JavaScript book, to learn hella quick!
I would go crazy for a copy of Cody's book!
Today might've turned out hella retarded if I hadn't seen this awesome post about Cody's crazy wicked book giveaway! Great idea Ben!
What a wicked way, to win this hella crazy deal, anyone who doesn't enter must be retarded and too lazy to post a comment!
The jQuery book was hella good. I'd rip through this one like a crazy fiend!
It's hella awesome that you got a few copies of this book to give away. One must be crazy and/or retarded to not want to participate in this awesome giveaway!
What a hella wicked idea, winning this would make me less retarded about JavaScript and instead make me a crazy lil JS Ninja
In Nothern California we say hella. As in "I could hella use a copy of Cody's book!" Definitely not a crazy contest idea, Ben.
This is wicked! Fingers crossed :)
What I love about Ben, is how wicked his blog is. It is hella crazy! Reading it will keep you from sounding retarded.
This marketing campaign is crazy slick, Ben.
that's one crazy contest. here's hoping i win!
hellawicked
What the hella am I doing in order to win a good JavaScript book?
I am putting this text in jsFiddle, clicking "Run" and hoping to see "true" in the alert - like I'm retarded - so I'll win this crazy comment comepition on a totally wicked site!
I just encountered a retarded hobo. It was hella crazy! He tried to steal my tickets to wicked [sic, as case is important in isValid()].
<3 Ross
What a crazy idea to prevent wicked form submission by retarded spam-bots for this hella cool contest. Just a brillant captcha-version.
wicked
Nice post, or should I say WICKED post !
Thank you !
hella brother, i'm not crazy
This is a hella wicked contest Ben!
I'm not retarded, but I do need to learn some wicked Javascript so I can get hella good at it and land myself a crazy cool job. :)
It would be crazy if this code didn't follow the convention of capitalizing the constructor method Comment.
What's crazy is that the Comment object is tightly coupled to a function outside of it's self. This means the Comment could not be used on another page unless the implementer knew to create the isFun() method.
Not to sound retarded but I would have made the isFun method a parameter to the Comment constructor. Because passing functions is hella cool.
Im putting my name in the hat for this crazy contest. I want my Javascript skills to be hella wicked and a bit less retarded : )
It would be crazy, hella, wicked if I won a copy.
I will go crazy if I don't win one of those hella wicked copies!
Thanks for the hella wicked giveaway. One would have to be crazy not to want a copy of this book. I need it for one of my retarded friends that can't grok JavaScript.
It would be wicked cool to get a copy of this book. Codey is the man and this book has been on my wish list for so long it's retarded.
Gazing longingly into Bella's eyes for two hours doesn't make Edward Cullen wicked at all.
I'm crazy...
Wicked fun, though I never use the word retarded to refer to people, because I have a cousin who is retarded, and I am sensitive to it. He's one of the coolest and sweetest of all of the people I know. And though I do, from time to time, like to attempt to drive men crazy, I do not cuss, so I won't use that other word...and if that means I don't win the contest. Oh well. :-/
What about modifying the code to use a table in the isFun() function to ease the reading of the code and code re-use?
BTW, I came across jQuery thanks to TiddlyWiki (www.tiddlywiki.org), a very powerful portable wiki based on JavaScript and jQuery.
crazy!
This is hella wicked but I do not understand why I am commenting, maybe because I am crazy or retarded. ;)
This is a hella wicked, crazy idea, although I do not use the word "retarded" in a derogatory fashion.
The Coachella music festival is held adjacent to the building that houses G4, the network that produces "Attack of the Show" and the thoroughly Chris-Hardwicked show "Web Soup". It b hangin' 'cross Wilshire from LaBreTarDEducationPits, yo. (Dis democrazy sez AWE-full spellins ok.)
And here's an alert: All of that's true.
hella wicked bro!
This contest is wicked crazy. I need to win so I'll no longer program so hella retarded. Even now, I use all four words when I only need one for a fun comment!
It sure would be hella sweet to get a copy of this book! Wicked contest btw.
Calling me crazy - i prefer enlightened in a different shade - but Cody is getting his well deserved $15 directly anyway!
:)
This contest is wicked sick, hella fun, and crazy awesome, but definitely not retarded.
Hella yes ... would be wicked crazy if my retarded ass won this book!
My love for that book is retardedly obvious. Some think I'm crazy. I hella want to win this contest! Wicked-awesome fun!
Hey guys, for anyone who had trouble following the code, I added a video walk-through in an attempt to explain the features. Hope that helps for anyone who was a little lost :D
Wicked crazy fires can be retarded using class A foam; it's a hella good fire retardant.
this comment is wicked hella crazy retarded, but it is fun
http://en.wikipedia.org/wiki/Hella_%28band%29
http://en.wikipedia.org/wiki/Wicked_%281931_film%29
http://en.wikipedia.org/wiki/Crazy
http://en.wikipedia.org/w/index.php?title=Retarded&redirect=no
@Ben,
I'm not lost, but a word that would've made my post better was. I should have said:
... Chris-Hardwicked (nerdisted) ...
http://img199.imageshack.us/img199/2615/imagehvc.jpg
JavaScript is hella wicked crazy retarded.
Wicked
Thanks for the video Ben. Crazy. Would love a wicked JavaScript book.
That is a good idea for a contest. Heck let's upgrade it to wicked good!
I want that wicked book!
A crazy handsome bastard such as myself could do a hell of a lot with that wicked js book. Hook it up Ben!
Wicked! I never thought to override the toString() method on my objects before.
That's crazy stuff! Hope I win the book!
I'm Enlightened!
Some code are wicked and short but unmaintainable.
Some code are hella simple but lengthy.
Some code are as crazy as spaghetti.
Some code are retarded as procedural.
yo' I'm enlightened by Javascript Enlightenment.
+ '' + "crazy try to break" wicked code /+alert("please give me the book");
I'd be crazy retarded to think I could win one hella of a wicked good book like this.
wicked price Ben... I hope I win.
Ben, it is a crazy good idea, I wish "R" word was not an option.
Hella crazy cool!
I knew there would be some wicked code in there. Hopefully I'm not completely retarded when it comes to javascript. It would be a hella thing to win this crazy book
this book is wicked cool, just like you and it is hella crazy that you give 3 of them away to us. i would surely make good use of this book since i am still too retarded for good javascript.
Are you from bean town? Being that this is a hell of a crazy wicked idea, it is like you are retarded. How do you like them apples?
An enlightingly valid wicked comment to post for getting Cody Lindleys JavaScript Enlightenment book from bennadel via velvetflair
alert('' || "An enlightingly valid comment to post for getting 'Cody Lindley's JavaScript Enlightenment' book from @bennadel and this is not XSS as its without script tag!");
Hella was crazy, but she was burned at the stake for being wicked. Isn't that retarded?
i am too RETARDED for this competition. i can't seem to grasp the CRAZY rules.
what a wickedly retarded contest!
This contest is hella wicked!
You'd have to be retarded not to pick me for the free book.
@Ben,
I am thinking from your comment that most of us have gotten it completely and totally wrong, and don't know what we are talking about at all, although, compared to you, we may be able to be classified as medically retarded (I am NOT making fun of retarded people, btw, that would be wicked, but I am merely stating what might be able to be proved as a medical fact).
It may be crazy to explain this, but:
The retarded classification is granted to people, I believe, with an IQ of below 70. So it is 69 or below. Is that ironic?
The IQ score is based on a quotient (the q part) of a person's chronological age, compared to his or her's 'intellectual age' (the i part). That is how they used to do it, although due to political correctness and people's sensitivities to different 'types' of intelligence, they may have officially changed it by now. They formulated tests, and those tests are designed to attempt to 'meassure' the brain activity of people with questions that supposedly do that. I guess an alternative method COULD involve hooking electrodes and other fancy medical equipment up to a person's head and physically meassure the activity going on in their brain, but my guess is this would not be cost effective.
I could be totally wrong with all of the above, but that is how I understand it. I can boast...I consider it a good thing that MY BQ is higher than my IQ. }:^D Though some would not consider that necessarily a good thing. But what can ya do? (and BQ does NOT stand for Body-Odor Quotient lmao)
Anyway, this may be a little OT, but @Webmanwalking, interestingly enough, your post reminded me of a case, I think it was in 1984 or 1987...Bowers Vs. Hardwick, and I think it was in West Virginia. It was a sodomy case. The hardwick part of your post reminded me of that. Sorry. Some memories of law school never get flushed out of your head.
ok, back to the part about our comments possibly wrong...I realize there could be some sort of or implementation, at which I would not have to use all of the words presented, including the 'cuss' word, but I thought I would try to cover all my bases just in case. Because, it would be totally and completely wicked cool and totally radical, dude, to win one of those wickedly cool javascript books. :D I could really, really, really, REALLY use a book on javascript @ my job, and I really love javascript and would love to have one to enhance my performance with this technology at work. :-). Ok. Now my comment has degraded down to begging. :-/ I guess I'll post a picture of my dog (puppy) begging next. Whatever works, I guess. :-)
What a neat contest. I don't want to enter for the winning as there are others who would benefit more (I'll buy the book, I promise!), but such a novel approach.
My wife teaches in special education and has injected me with a modicum of sensitivity to the "lesser abled," but what is so fascinating is that most of what used to be clinical terms to describe these conditions eventually find a place in the vituperative vernacular. Idiot, imbecile, retarded, all of their original clinical uses rendered obsolete because their usage eventually recast their literal meaning as offensive.
And full circle back to JavaScript, it's amazing that an unexpected usage can change the meaning (and value)
@Ben - between you and the author of this book, what a mitzvah to share and export this understanding of JavaScript - these concepts are what's going to continue building use cases for node.js, which IMHO is the single-greatest thing since butterscotch pudding. And I love me some butterscotch pudding.
I'm pleased you are offering this hellawickedlycrazynonretarded contest and I hope to win. I've been looking forward to checking this book out for a few weeks now.
@Anna,
Chris Hardwick is not a sodomite, as far as I know. He's the nerdy and very funny comedian host of "Web Soup" on G4 and of the (currently, overall) #21 ranked podcast, The Nerdist. That's more popular than the Ricky Gervais podcast! Or TED Talks!
He sometimes says "You've just been nerdisted!", hence the Hardwicked reference.
But again, not a sodomy defendant, to the best of my knowledge.
I meant to add that the reason that by comparison, we would be classified as retarded is because of the relative intelligence of @Ben raising the bar higher. The tests make comparison of current intelligence at that age level for the meassurements of chronological age and intellectual age, and it takes an average from that. If @Ben were smarter, more intelligent, then that would bring the average up, and would impact all of those falling below @Ben's level of intelligence. At his age, all of his peers, those who were of lower intelligence than what he possesses would have a lower I.Q. than they would were he not skewering the results, and those who were below his chronological age would not be able to rise as high on the 'intellectual age', because what the average person at that age would know would be raised, due to @Ben's relative intelligence.
I somehow forgot to explain all of this. :-)
@Brian - in another court case, when it was still considered 'pc' to call someone an imbecile, the court decided that 'Three generations of imbeciles are enough!!!'...allowing and ruling constitutional mandatory sterilization of people inflicted with 'imbecilism', ending a genetic streak that spanned over 3 generations, and taking those genes out of the gene pool. I never did hear of the time when it was not considered an insult to call someone an idiot, I have no knowledge of the origin of that word. I will buy a book if I don't win the contest, and I am sure my previous comments have taken me out of the running and have ruined my chance anyway. :-) It would just be highly useful to me. And I ain't rich, so I'll have to budget for it if I end up having to purchase it. :-)
@Anna - hope you win just on the merit of substance. "Moron," too, if I remember correctly, was all wrapped up in eugenics. My wife told me about some scale they used to use which classified them as moron, idiot, or imbecile by IQ. I'm a linguistic utilitarian on principle (what would you expect from an English major that codes because he loves syntax sooo much?) so it vexes me that we have to abandon clinical terms because of negative, non-literal associations. If you care about people in spite of nerd passion, though, it is what it is. And as much as I scream "idiot" or "moron" while driving, I'd hate to think someone walking by who fits the clinical definition of those terms would feel lesser for my insensitivity. Hence the new push to move away from MR as the clinical term in the current state of psychology/education. In a matter of years, we won't be any more sensitive about the perjorative use of "retard" than we are now about idiot, fortunately, and they'll have some new clinical term for the general population to corrupt.
And JavaScript will still be awesome!
@Brian,
Thanks! And agreed -- it does irritate me that certain words have to be taken out and not uttered due to people's overuse of them and also to people perverting the original sense of them (it is a perversion, using a word in a way it is not meant to be used).
I've become de-sensitized to it, to some degree, because of all of the ignorant fools (I'm sure that came from somewhere) who throw terms around to be offensive.
There is a certain word that can't even hardly be said, which at one time was a completely acceptible and legal term for a group of people. The technical definition of this term was 'an ignorant person'. It came from 'ignorant'...nothing else. And yet, ignorant people (how ironic!!!) took it and turned it into this word that people are afraid to even say anymore, or that can cause such a raucus. In some dictionaries, the older ones, the term is still defined. And it is defined as an 'ignorant person'. It has been taken out of some dictionaries, and in others, there is some bogus bs about the word, which isn't even historically correct.
I think being a woman is WAY different. Because there are SO, SO many derogatory terms for women, and it has just become more or less commonplace for those terms to be thrown around and for women to accept them as 'compliments' and/or 'jokes'. I would say those words, those terms, used to describe women, are on the same level as the word mentioned above, but everyone pretty much expects us to just accept them. And if we don't, the we are bad sports, or we are way too sensitive, or we need to lighten up, or we are taking things way too seriously. There really aren't equivalent terms for men in general.
I've taken a shellacking for my unenlightened (but well intentioned) abuse of JS; so I could use some Cody Lindley illumination!
I nearly missed this due to procrastination. I had the crazy idea yesterday that I would post later, and nearly forgot until by random chance I checked the site today with only 2 hours left to submit.
Thanks, Ben, for all your wicked blog posts, you are hella awesome!
WiRetaCheLlaEded - pronounced "Pick Me!"
This is retarded!
@Brian,
My father was a clinical psychologist. One of his day-to-day functions was to administer IQ tests. So I can tell you how it used to be: 0-40 was idiot. 40-60 was imbecile. 60-80 was moron. 80-90 was dull normal. And 90-100 was normal.
Sometimes you run into definitions that seem unnecessarily precise on the boundary numbers. I suspect that they're basing their definitions on standard deviations from the mean. But a more useful definition is somewhat vague, based more on implications for care: Idiots require continual care and supervision. Imbeciles can dress themselves, clean up after themselves, etc. Morons can even hold a job. Those are more useful boundaries. Also, most IQ tests don't generally measure in those ranges, so they're more estimates in any case.
Among folks who are NOT mental health professionals, idiot, imbecile and moron became more derogatory over time, a process known as pejoration, as did retarded. Retarded used to be a euphemism, replacing slow or slow-minded (which seemed to indicate that they would never catch up). Retarded just meant further back in the pack, as if to say, given enough time, they would catch up.
Hope this helps.
@WebManWalking,
Whoa, then that would mean by my IQ that I am WAY above normal (although my BQ is still higher than my IQ :^)) That was useful information, though. Thanks!
I thought retarded came from the...I THINK Latin (or was it Italian) term in music "Ritard" (or it could be "ritardo"), which means "slow" as in "slow down". I always thought that retarded just meant the person was slow. (and then, of course, people used it to be offensive).
Hey guys, thanks so much for participating! I hope everyone had a great week programming and rocking out with their JavaScript out.
.... and the winners are:
Adam - It sure would be hella sweet to get a copy of this book! Wicked contest btw.
JAlpino - Wicked! I never thought to override the toString() method on my objects before.
Rob Dix - The jQuery book was hella good. I'd rip through this one like a crazy fiend!
Shoot me an email at - ben[at]bennadel.com - and I'll give you the discount code for the free book.
Cheers!
@Anna: Retarded just means late again. Tardy means late. The sounds of a marching band's drums reach the stands behind the music, resulting in a retarded beat. Behind, late.
@Adam, @JAlpino, and @Rob Dix,
Congratulations!
@WebManWalking,
When I said that "Ritard" in music meant "slow", what I meant was as in "slow down", as in when you are playing the piano, and there is a direction in italics above the staff that says "Ritard", and any piano player who has studied and played any amount of time knows that word means to "slow your playing down".
French being latin-based, in french, tard means slow as well, as in "Parlez plus tard alors je peux te comprends, s'il vous plait." That means, "Speak slower, please, so that I may understand you".
Woohoo! Thanks Ben and Cody!
First time I have ever won anything!!! Thank you Ben.
Congrats to the winners. Now off to buy the book.
@WebManWalking, Thanks for your kind explanation. As a father of a son with Autism, I really appreciate that.
@Anna
"in french, tard means slow as well"
That is simply false. "Tard" means late.
wicked
@Guillaume,
true...my mistake. Pardon. I don't get to practice my french too much in this non-french speaking nation. I apologize. Do I know you? I knew a Guillaume once, who was french, but I don't think he spelled his name that way. But I could be wrong.
@Ben,
I hope you are surviving that hurricane Irene and the aftermath, and that everything is fine with you up there.
A wicked JavaScript book for the awesome reader? Yes. Please.
Wicked cool contest, I love little challenges like this. Was hella sad to see you add the video, decreases my chances of winning!
What do you call a helicopter with jet propulsion, does loop-da-loops, and has no seat belts?
A hellacopter!
I know it is late to win but figured I'd comment anyway.
Wicked is an interesting word. In the Northeast where I live you can use the word wicked as in "wicked cool" and people know you mean very good. But if you you use wicked that way in other parts of the country they have no idea what you mean and look at you like you are hella retarded. Once you explain it to them they just think you're crazy.
:)