<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>The Wit and Ramblings of David Giard - JavaScript</title>
    <link>http://www.davidgiard.com/</link>
    <description>Demanding rigidly defined areas of doubt and uncertainty</description>
    <language>en-us</language>
    <copyright>David Giard</copyright>
    <lastBuildDate>Mon, 03 Jun 2013 18:10:00 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.0.7226.0</generator>
    <managingEditor>davidgiard@davidgiard.com</managingEditor>
    <webMaster>davidgiard@davidgiard.com</webMaster>
    <item>
      <trackback:ping>http://www.davidgiard.com/Trackback.aspx?guid=afd494a2-96ac-42ed-ba9e-5d43d9412231</trackback:ping>
      <pingback:server>http://www.davidgiard.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.davidgiard.com/PermaLink,guid,afd494a2-96ac-42ed-ba9e-5d43d9412231.aspx</pingback:target>
      <dc:creator>David Giard</dc:creator>
      <wfw:comment>http://www.davidgiard.com/CommentView,guid,afd494a2-96ac-42ed-ba9e-5d43d9412231.aspx</wfw:comment>
      <wfw:commentRss>http://www.davidgiard.com/SyndicationService.asmx/GetEntryCommentsRss?guid=afd494a2-96ac-42ed-ba9e-5d43d9412231</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <img border="0" src="http://www.davidgiard.com/content/binary/TechnologyAndFriends.gif" />
        </p>
        <p>
          <strong> Episode 268 </strong>
        </p>
        <p>
          <a href="http://technologyandfriends.com/SubText/archive/2013/06/03/tf268.aspx" target="_blank"> John
Papa on Single Page Applications </a>
        </p>
        <img width="0" height="0" src="http://www.davidgiard.com/aggbug.ashx?id=afd494a2-96ac-42ed-ba9e-5d43d9412231" />
      </body>
      <title>John Papa on Single Page Applications</title>
      <guid isPermaLink="false">http://www.davidgiard.com/PermaLink,guid,afd494a2-96ac-42ed-ba9e-5d43d9412231.aspx</guid>
      <link>http://www.davidgiard.com/2013/06/03/JohnPapaOnSinglePageApplications.aspx</link>
      <pubDate>Mon, 03 Jun 2013 18:10:00 GMT</pubDate>
      <description>&lt;p&gt;
&lt;img border="0" src="http://www.davidgiard.com/content/binary/TechnologyAndFriends.gif" /&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt; Episode 268 &lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://technologyandfriends.com/SubText/archive/2013/06/03/tf268.aspx" target="_blank"&gt; John
Papa on Single Page Applications &lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.davidgiard.com/aggbug.ashx?id=afd494a2-96ac-42ed-ba9e-5d43d9412231" /&gt;</description>
      <comments>http://www.davidgiard.com/CommentView,guid,afd494a2-96ac-42ed-ba9e-5d43d9412231.aspx</comments>
      <category>ASP.NET</category>
      <category>JavaScript</category>
      <category>Technology and Friends</category>
      <category>Video</category>
    </item>
    <item>
      <trackback:ping>http://www.davidgiard.com/Trackback.aspx?guid=2d9c17d5-d4a2-44aa-ae06-6e99c651a185</trackback:ping>
      <pingback:server>http://www.davidgiard.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.davidgiard.com/PermaLink,guid,2d9c17d5-d4a2-44aa-ae06-6e99c651a185.aspx</pingback:target>
      <dc:creator>David Giard</dc:creator>
      <wfw:comment>http://www.davidgiard.com/CommentView,guid,2d9c17d5-d4a2-44aa-ae06-6e99c651a185.aspx</wfw:comment>
      <wfw:commentRss>http://www.davidgiard.com/SyndicationService.asmx/GetEntryCommentsRss?guid=2d9c17d5-d4a2-44aa-ae06-6e99c651a185</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <img border="0" src="http://www.davidgiard.com/content/binary/TechnologyAndFriends.gif" />
        </p>
        <p>
          <strong>Episode 231</strong>
        </p>
        <p>
          <a href="http://technologyandfriends.com/SubText/archive/2012/09/24/tf231.aspx" target="_blank"> Chris
Powers on Code Reuse </a>
        </p>
        <img width="0" height="0" src="http://www.davidgiard.com/aggbug.ashx?id=2d9c17d5-d4a2-44aa-ae06-6e99c651a185" />
      </body>
      <title>Chris Powers on Code Reuse</title>
      <guid isPermaLink="false">http://www.davidgiard.com/PermaLink,guid,2d9c17d5-d4a2-44aa-ae06-6e99c651a185.aspx</guid>
      <link>http://www.davidgiard.com/2012/09/24/ChrisPowersOnCodeReuse.aspx</link>
      <pubDate>Mon, 24 Sep 2012 13:03:36 GMT</pubDate>
      <description>&lt;p&gt;
&lt;img border="0" src="http://www.davidgiard.com/content/binary/TechnologyAndFriends.gif" /&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Episode 231&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://technologyandfriends.com/SubText/archive/2012/09/24/tf231.aspx" target="_blank"&gt; Chris
Powers on Code Reuse &lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.davidgiard.com/aggbug.ashx?id=2d9c17d5-d4a2-44aa-ae06-6e99c651a185" /&gt;</description>
      <comments>http://www.davidgiard.com/CommentView,guid,2d9c17d5-d4a2-44aa-ae06-6e99c651a185.aspx</comments>
      <category>JavaScript</category>
      <category>Technology and Friends</category>
      <category>Visual Studio</category>
    </item>
    <item>
      <trackback:ping>http://www.davidgiard.com/Trackback.aspx?guid=f18e8cee-d9b7-4ed8-b709-2265bbf6780f</trackback:ping>
      <pingback:server>http://www.davidgiard.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.davidgiard.com/PermaLink,guid,f18e8cee-d9b7-4ed8-b709-2265bbf6780f.aspx</pingback:target>
      <dc:creator>David Giard</dc:creator>
      <wfw:comment>http://www.davidgiard.com/CommentView,guid,f18e8cee-d9b7-4ed8-b709-2265bbf6780f.aspx</wfw:comment>
      <wfw:commentRss>http://www.davidgiard.com/SyndicationService.asmx/GetEntryCommentsRss?guid=f18e8cee-d9b7-4ed8-b709-2265bbf6780f</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <img src="http://www.davidgiard.com/content/binary/BooksOfDavid.gif" />
        </p>
        <p>
JavaScript’s popularity proves how useful people have found the language. Novices
use it to add simple validations to web forms, while advanced build amazing applications
with JavaScript.
</p>
        <p>
Yet, for all its utility, many look at JavaScript with disdain and fear, pointing
to dangerous features and to the difficult of dealing with the browser's Document
Object Model.
</p>
        <p>
In <em>JavaScript: The Good Parts</em>, Douglas Crockford distinguishes between the
good features of JavaScript that make it and elegant and powerful language; and the
bad parts that make it dangerous and difficult to understand. Crockford’s message
is to use the good parts and avoid the bad parts and stop fearing JavaScript.
</p>
        <p>
According to Crockford, most people misunderstand JavaScript and so they misuse it;
then, they complain about the language.
</p>
        <p>
Crockford acknowledges that the designers of JavaScript made some mistakes (global
variables, for example), but that there are enough good features of the language to
make it appealing to a wide range of users writing a wide range of applications. He
notes that JavaScript succeeded as a platform for creating client code for the web
– something that that the more powerful Java language attempted and failed badly –
and that this proves JavaScript’s power.
</p>
        <p>
Applications will be better and developers happier, notes Crockford, if developers
avoid the bad parts of the language. For example, always use the "===" operator,
which returns what most users expect because it doesn't do any type coercion. Avoid
the confusion of the "==" operator, Crockford recommends.
</p>
        <p>
Crockford's style is concise and straightforward. At fewer than 200 pages, the book
has no room for distractions. Regular Expressions are presented and described and
examples are shown how to use them. Crockford clearly describes Closures, a feature
that is likely new to many developers; and he spells out how callbacks are implemented
in JavaScript. 
</p>
        <p>
Before reading this book, I was unaware of implied semicolons in JavaScript and whey
they can be dangerous. Crockford spelled out the dangers and how to avoid them very
clearly.
</p>
        <p>
JavaScript can be a great language if you confine your programs to using the best
parts of the language and steer clear of most of the dangerous features. This book
will help distinguish the two.
</p>
        <img width="0" height="0" src="http://www.davidgiard.com/aggbug.ashx?id=f18e8cee-d9b7-4ed8-b709-2265bbf6780f" />
      </body>
      <title>JavaScript: The Good Parts</title>
      <guid isPermaLink="false">http://www.davidgiard.com/PermaLink,guid,f18e8cee-d9b7-4ed8-b709-2265bbf6780f.aspx</guid>
      <link>http://www.davidgiard.com/2012/08/19/JavaScriptTheGoodParts.aspx</link>
      <pubDate>Sun, 19 Aug 2012 02:36:23 GMT</pubDate>
      <description>&lt;p&gt;
&lt;img src="http://www.davidgiard.com/content/binary/BooksOfDavid.gif" /&gt;
&lt;/p&gt;
&lt;p&gt;
JavaScript’s popularity proves how useful people have found the language. Novices
use it to add simple validations to web forms, while advanced build amazing applications
with JavaScript.
&lt;/p&gt;
&lt;p&gt;
Yet, for all its utility, many look at JavaScript with disdain and fear, pointing
to dangerous features and to the difficult of dealing with the browser's Document
Object Model.
&lt;/p&gt;
&lt;p&gt;
In &lt;em&gt;JavaScript: The Good Parts&lt;/em&gt;, Douglas Crockford distinguishes between the
good features of JavaScript that make it and elegant and powerful language; and the
bad parts that make it dangerous and difficult to understand. Crockford’s message
is to use the good parts and avoid the bad parts and stop fearing JavaScript.
&lt;/p&gt;
&lt;p&gt;
According to Crockford, most people misunderstand JavaScript and so they misuse it;
then, they complain about the language.
&lt;/p&gt;
&lt;p&gt;
Crockford acknowledges that the designers of JavaScript made some mistakes (global
variables, for example), but that there are enough good features of the language to
make it appealing to a wide range of users writing a wide range of applications. He
notes that JavaScript succeeded as a platform for creating client code for the web
– something that that the more powerful Java language attempted and failed badly –
and that this proves JavaScript’s power.
&lt;/p&gt;
&lt;p&gt;
Applications will be better and developers happier, notes Crockford, if developers
avoid the bad parts of the language. For example, always use the &amp;quot;===&amp;quot; operator,
which returns what most users expect because it doesn't do any type coercion. Avoid
the confusion of the &amp;quot;==&amp;quot; operator, Crockford recommends.
&lt;/p&gt;
&lt;p&gt;
Crockford's style is concise and straightforward. At fewer than 200 pages, the book
has no room for distractions. Regular Expressions are presented and described and
examples are shown how to use them. Crockford clearly describes Closures, a feature
that is likely new to many developers; and he spells out how callbacks are implemented
in JavaScript. 
&lt;/p&gt;
&lt;p&gt;
Before reading this book, I was unaware of implied semicolons in JavaScript and whey
they can be dangerous. Crockford spelled out the dangers and how to avoid them very
clearly.
&lt;/p&gt;
&lt;p&gt;
JavaScript can be a great language if you confine your programs to using the best
parts of the language and steer clear of most of the dangerous features. This book
will help distinguish the two.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.davidgiard.com/aggbug.ashx?id=f18e8cee-d9b7-4ed8-b709-2265bbf6780f" /&gt;</description>
      <comments>http://www.davidgiard.com/CommentView,guid,f18e8cee-d9b7-4ed8-b709-2265bbf6780f.aspx</comments>
      <category>Books</category>
      <category>JavaScript</category>
    </item>
    <item>
      <trackback:ping>http://www.davidgiard.com/Trackback.aspx?guid=fcbccd7e-fb4c-4871-a6a4-1dffd04aa009</trackback:ping>
      <pingback:server>http://www.davidgiard.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.davidgiard.com/PermaLink,guid,fcbccd7e-fb4c-4871-a6a4-1dffd04aa009.aspx</pingback:target>
      <dc:creator>David Giard</dc:creator>
      <wfw:comment>http://www.davidgiard.com/CommentView,guid,fcbccd7e-fb4c-4871-a6a4-1dffd04aa009.aspx</wfw:comment>
      <wfw:commentRss>http://www.davidgiard.com/SyndicationService.asmx/GetEntryCommentsRss?guid=fcbccd7e-fb4c-4871-a6a4-1dffd04aa009</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <img border="0" src="http://www.davidgiard.com/content/binary/TechnologyAndFriends.gif" />
        </p>
        <p>
          <strong>Episode 223</strong>
        </p>
        <p>
          <a href="http://technologyandfriends.com/SubText/archive/2012/07/30/tf223.aspx" target="_blank">Joel
Cochran on KnockoutJS </a>
        </p>
        <img width="0" height="0" src="http://www.davidgiard.com/aggbug.ashx?id=fcbccd7e-fb4c-4871-a6a4-1dffd04aa009" />
      </body>
      <title>Joel Cochran on KnockoutJS </title>
      <guid isPermaLink="false">http://www.davidgiard.com/PermaLink,guid,fcbccd7e-fb4c-4871-a6a4-1dffd04aa009.aspx</guid>
      <link>http://www.davidgiard.com/2012/07/30/JoelCochranOnKnockoutJS.aspx</link>
      <pubDate>Mon, 30 Jul 2012 15:57:00 GMT</pubDate>
      <description>&lt;p&gt;
&lt;img border="0" src="http://www.davidgiard.com/content/binary/TechnologyAndFriends.gif" /&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Episode 223&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://technologyandfriends.com/SubText/archive/2012/07/30/tf223.aspx" target="_blank"&gt;Joel
Cochran on KnockoutJS &lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.davidgiard.com/aggbug.ashx?id=fcbccd7e-fb4c-4871-a6a4-1dffd04aa009" /&gt;</description>
      <comments>http://www.davidgiard.com/CommentView,guid,fcbccd7e-fb4c-4871-a6a4-1dffd04aa009.aspx</comments>
      <category>JavaScript</category>
      <category>Technology and Friends</category>
      <category>Video</category>
    </item>
    <item>
      <trackback:ping>http://www.davidgiard.com/Trackback.aspx?guid=e61950b1-6abe-4dc4-9d3d-eb601871ac3c</trackback:ping>
      <pingback:server>http://www.davidgiard.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.davidgiard.com/PermaLink,guid,e61950b1-6abe-4dc4-9d3d-eb601871ac3c.aspx</pingback:target>
      <dc:creator>David Giard</dc:creator>
      <wfw:comment>http://www.davidgiard.com/CommentView,guid,e61950b1-6abe-4dc4-9d3d-eb601871ac3c.aspx</wfw:comment>
      <wfw:commentRss>http://www.davidgiard.com/SyndicationService.asmx/GetEntryCommentsRss?guid=e61950b1-6abe-4dc4-9d3d-eb601871ac3c</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <img border="0" src="http://www.davidgiard.com/content/binary/TechnologyAndFriends.gif" />
        </p>
        <p>
          <strong>Episode 214</strong>
        </p>
        <p>
          <a href="http://technologyandfriends.com/SubText/archive/2012/05/28/tf214.aspx" target="_blank">Elijah
Manor on AmplifyJS</a>
        </p>
        <img width="0" height="0" src="http://www.davidgiard.com/aggbug.ashx?id=e61950b1-6abe-4dc4-9d3d-eb601871ac3c" />
      </body>
      <title>Elijah Manor on AmplifyJS</title>
      <guid isPermaLink="false">http://www.davidgiard.com/PermaLink,guid,e61950b1-6abe-4dc4-9d3d-eb601871ac3c.aspx</guid>
      <link>http://www.davidgiard.com/2012/05/28/ElijahManorOnAmplifyJS.aspx</link>
      <pubDate>Mon, 28 May 2012 21:34:00 GMT</pubDate>
      <description>&lt;p&gt;
&lt;img border="0" src="http://www.davidgiard.com/content/binary/TechnologyAndFriends.gif" /&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Episode 214&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://technologyandfriends.com/SubText/archive/2012/05/28/tf214.aspx" target="_blank"&gt;Elijah
Manor on AmplifyJS&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.davidgiard.com/aggbug.ashx?id=e61950b1-6abe-4dc4-9d3d-eb601871ac3c" /&gt;</description>
      <comments>http://www.davidgiard.com/CommentView,guid,e61950b1-6abe-4dc4-9d3d-eb601871ac3c.aspx</comments>
      <category>JavaScript</category>
      <category>Technology and Friends</category>
      <category>Video</category>
    </item>
    <item>
      <trackback:ping>http://www.davidgiard.com/Trackback.aspx?guid=597753ce-edfb-4d8d-b6ee-4f07cbc9d7c3</trackback:ping>
      <pingback:server>http://www.davidgiard.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.davidgiard.com/PermaLink,guid,597753ce-edfb-4d8d-b6ee-4f07cbc9d7c3.aspx</pingback:target>
      <dc:creator>David Giard</dc:creator>
      <wfw:comment>http://www.davidgiard.com/CommentView,guid,597753ce-edfb-4d8d-b6ee-4f07cbc9d7c3.aspx</wfw:comment>
      <wfw:commentRss>http://www.davidgiard.com/SyndicationService.asmx/GetEntryCommentsRss?guid=597753ce-edfb-4d8d-b6ee-4f07cbc9d7c3</wfw:commentRss>
      <slash:comments>3</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
At Codeslingers last night, someone pulled out some coding Katas. For those who don’t
know, a Kata is a coding exercise that is designed to practice your programming skills,
rather than to solve a particular business problem. I was handed the classic “FizzBuzz”
problem. The assignment:
</p>
        <p>
Create a function that will print the integers from 1 to 100 with the following exceptions:
</p>
        <ul>
          <li>
If a number is divisible by 3, print the word “Fizz” in place of that number.</li>
          <li>
If a number is divisible by 5, print the word “Buzz” in place of that number.</li>
          <li>
If a number is divisible by both 3 and 5, print the word “FizzBuzz” in place of that
number.</li>
        </ul>
        <p>
The output should look something like the following:
</p>
        <pre class="csharpcode">1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
16</pre>
        <p>
I started with a C# console application because that is the language with which I
am most familiar. It was able to finish the following in under 2 minutes. It took
me 5 minutes to write the unit tests.
</p>
        <pre class="csharpcode">
          <span class="kwrd">class</span> Program { <span class="kwrd">static</span><span class="kwrd">void</span> Main(<span class="kwrd">string</span>[]
args) { <span class="kwrd">for</span> (<span class="kwrd">int</span> i = 1; i &lt;
100; i++) { var p = FizzBuzz(i); Console.WriteLine(p); } Console.ReadLine(); } <span class="kwrd">protected</span><span class="kwrd">static</span><span class="kwrd">string</span> FizzBuzz(<span class="kwrd">int</span> i)
{ <span class="kwrd">if</span> (i % 15 == 0) <span class="kwrd">return</span><span class="str">"FizzBuzz"</span>; <span class="kwrd">if</span> (i
% 3 == 0) <span class="kwrd">return</span><span class="str">"Fizz"</span>; <span class="kwrd">if</span> (i
% 5 == 0) <span class="kwrd">return</span><span class="str">"Buzz"</span>; <span class="kwrd">return</span> i.ToString();
} }</pre>
        <p>
          <style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
I only occasionally code in JavaScript, so I tackled that language next. Someone recommended
using <a title="http://jsfiddle.net/&#xD;&#xA;" href="http://jsfiddle.net/">http://jsfiddle.net/ 
<br /></a>as an online IDE for writing and sharing JavaScript, so I tried it and liked it.
Of course, JavaScript is a dynamic language and one of my big challenges was spelling
things correctly without all the help Visual Studio provides when writing in a statically-typed
language. In my case, I misspelled the id of a div, which cost me at least 15 minutes.
I created the following boilerplate HTML:
</p>
        <pre class="csharpcode">&lt;html&gt;
    &lt;body&gt;
        &lt;div id=<span class="str">"fizzbuzz"</span>&gt;&lt;/div&gt;
&lt;/body&gt; &lt;/html&gt;</pre>
        <p>
          <style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
Then, I used the following JavaScript (plus a bit of jQuery) to output the FizzBuzz
results:
</p>
        <pre class="csharpcode">
          <span class="kwrd">for</span> (i = 1; i &lt;= 100; i++) {
$(<span class="str">"#fizzbuzz"</span>).append(<span class="kwrd">function</span>()
{ <span class="kwrd">var</span> newLine = i; <span class="kwrd">if</span> (i % 3 ===
0) { newLine = <span class="str">"Fizz"</span>; } <span class="kwrd">if</span> (i
% 5 === 0) { newLine = <span class="str">"Buzz"</span>; } <span class="kwrd">if</span> (i
% 15 === 0) { newLine = <span class="str">"FizzBuzz"</span>; } <span class="kwrd">var</span> newDiv
= $(<span class="str">"&lt;div&gt;"</span>).text(newLine); <span class="kwrd">return</span> newDiv;
}); }</pre>
        <p>
          <style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
A simple program like this provides a fun way to practice an old language and to learn
a new language. Next up, I’ll try this program with F# and Ruby, since I have very
little experience with these languages.
</p>
        <img width="0" height="0" src="http://www.davidgiard.com/aggbug.ashx?id=597753ce-edfb-4d8d-b6ee-4f07cbc9d7c3" />
      </body>
      <title>FizzBuzz Kata</title>
      <guid isPermaLink="false">http://www.davidgiard.com/PermaLink,guid,597753ce-edfb-4d8d-b6ee-4f07cbc9d7c3.aspx</guid>
      <link>http://www.davidgiard.com/2012/05/03/FizzBuzzKata.aspx</link>
      <pubDate>Thu, 03 May 2012 23:40:00 GMT</pubDate>
      <description>&lt;p&gt;
At Codeslingers last night, someone pulled out some coding Katas. For those who don’t
know, a Kata is a coding exercise that is designed to practice your programming skills,
rather than to solve a particular business problem. I was handed the classic “FizzBuzz”
problem. The assignment:
&lt;/p&gt;
&lt;p&gt;
Create a function that will print the integers from 1 to 100 with the following exceptions:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
If a number is divisible by 3, print the word “Fizz” in place of that number.&lt;/li&gt;
&lt;li&gt;
If a number is divisible by 5, print the word “Buzz” in place of that number.&lt;/li&gt;
&lt;li&gt;
If a number is divisible by both 3 and 5, print the word “FizzBuzz” in place of that
number.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
The output should look something like the following:
&lt;/p&gt;
&lt;pre class="csharpcode"&gt;1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
16&lt;/pre&gt;
&lt;p&gt;
I started with a C# console application because that is the language with which I
am most familiar. It was able to finish the following in under 2 minutes. It took
me 5 minutes to write the unit tests.
&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;class&lt;/span&gt; Program { &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Main(&lt;span class="kwrd"&gt;string&lt;/span&gt;[]
args) { &lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; i = 1; i &amp;lt;
100; i++) { var p = FizzBuzz(i); Console.WriteLine(p); } Console.ReadLine(); } &lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; FizzBuzz(&lt;span class="kwrd"&gt;int&lt;/span&gt; i)
{ &lt;span class="kwrd"&gt;if&lt;/span&gt; (i % 15 == 0) &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="str"&gt;&amp;quot;FizzBuzz&amp;quot;&lt;/span&gt;; &lt;span class="kwrd"&gt;if&lt;/span&gt; (i
% 3 == 0) &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="str"&gt;&amp;quot;Fizz&amp;quot;&lt;/span&gt;; &lt;span class="kwrd"&gt;if&lt;/span&gt; (i
% 5 == 0) &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="str"&gt;&amp;quot;Buzz&amp;quot;&lt;/span&gt;; &lt;span class="kwrd"&gt;return&lt;/span&gt; i.ToString();
} }&lt;/pre&gt;
&lt;p&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;
I only occasionally code in JavaScript, so I tackled that language next. Someone recommended
using &lt;a title="http://jsfiddle.net/&amp;#13;&amp;#10;" href="http://jsfiddle.net/"&gt;http://jsfiddle.net/ 
&lt;br /&gt;
&lt;/a&gt;as an online IDE for writing and sharing JavaScript, so I tried it and liked it.
Of course, JavaScript is a dynamic language and one of my big challenges was spelling
things correctly without all the help Visual Studio provides when writing in a statically-typed
language. In my case, I misspelled the id of a div, which cost me at least 15 minutes.
I created the following boilerplate HTML:
&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&amp;lt;html&amp;gt;
    &amp;lt;body&amp;gt;
        &amp;lt;div id=&lt;span class="str"&gt;&amp;quot;fizzbuzz&amp;quot;&lt;/span&gt;&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt; &amp;lt;/html&amp;gt;&lt;/pre&gt;
&lt;p&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;
Then, I used the following JavaScript (plus a bit of jQuery) to output the FizzBuzz
results:
&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;for&lt;/span&gt; (i = 1; i &amp;lt;= 100; i++) {
$(&lt;span class="str"&gt;&amp;quot;#fizzbuzz&amp;quot;&lt;/span&gt;).append(&lt;span class="kwrd"&gt;function&lt;/span&gt;()
{ &lt;span class="kwrd"&gt;var&lt;/span&gt; newLine = i; &lt;span class="kwrd"&gt;if&lt;/span&gt; (i % 3 ===
0) { newLine = &lt;span class="str"&gt;&amp;quot;Fizz&amp;quot;&lt;/span&gt;; } &lt;span class="kwrd"&gt;if&lt;/span&gt; (i
% 5 === 0) { newLine = &lt;span class="str"&gt;&amp;quot;Buzz&amp;quot;&lt;/span&gt;; } &lt;span class="kwrd"&gt;if&lt;/span&gt; (i
% 15 === 0) { newLine = &lt;span class="str"&gt;&amp;quot;FizzBuzz&amp;quot;&lt;/span&gt;; } &lt;span class="kwrd"&gt;var&lt;/span&gt; newDiv
= $(&lt;span class="str"&gt;&amp;quot;&amp;lt;div&amp;gt;&amp;quot;&lt;/span&gt;).text(newLine); &lt;span class="kwrd"&gt;return&lt;/span&gt; newDiv;
}); }&lt;/pre&gt;
&lt;p&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;
A simple program like this provides a fun way to practice an old language and to learn
a new language. Next up, I’ll try this program with F# and Ruby, since I have very
little experience with these languages.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.davidgiard.com/aggbug.ashx?id=597753ce-edfb-4d8d-b6ee-4f07cbc9d7c3" /&gt;</description>
      <comments>http://www.davidgiard.com/CommentView,guid,597753ce-edfb-4d8d-b6ee-4f07cbc9d7c3.aspx</comments>
      <category>C#</category>
      <category>JavaScript</category>
    </item>
    <item>
      <trackback:ping>http://www.davidgiard.com/Trackback.aspx?guid=1beedf7e-597c-4633-8c32-5942a24ce141</trackback:ping>
      <pingback:server>http://www.davidgiard.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.davidgiard.com/PermaLink,guid,1beedf7e-597c-4633-8c32-5942a24ce141.aspx</pingback:target>
      <dc:creator>David Giard</dc:creator>
      <wfw:comment>http://www.davidgiard.com/CommentView,guid,1beedf7e-597c-4633-8c32-5942a24ce141.aspx</wfw:comment>
      <wfw:commentRss>http://www.davidgiard.com/SyndicationService.asmx/GetEntryCommentsRss?guid=1beedf7e-597c-4633-8c32-5942a24ce141</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <img border="0" src="http://www.davidgiard.com/content/binary/TechnologyAndFriends.gif" />
        </p>
        <p>
          <strong>Episode 192</strong>
        </p>
        <p>
          <a href="http://technologyandfriends.com/SubText/archive/2012/01/16/tf192.aspx" target="_blank"> Stephen
Walther on the Ajax toolkit </a>
        </p>
        <img width="0" height="0" src="http://www.davidgiard.com/aggbug.ashx?id=1beedf7e-597c-4633-8c32-5942a24ce141" />
      </body>
      <title>Stephen Walther on the Ajax toolkit</title>
      <guid isPermaLink="false">http://www.davidgiard.com/PermaLink,guid,1beedf7e-597c-4633-8c32-5942a24ce141.aspx</guid>
      <link>http://www.davidgiard.com/2012/01/16/StephenWaltherOnTheAjaxToolkit.aspx</link>
      <pubDate>Mon, 16 Jan 2012 16:15:00 GMT</pubDate>
      <description>&lt;p&gt;
&lt;img border="0" src="http://www.davidgiard.com/content/binary/TechnologyAndFriends.gif" /&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Episode 192&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://technologyandfriends.com/SubText/archive/2012/01/16/tf192.aspx" target="_blank"&gt; Stephen
Walther on the Ajax toolkit &lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.davidgiard.com/aggbug.ashx?id=1beedf7e-597c-4633-8c32-5942a24ce141" /&gt;</description>
      <comments>http://www.davidgiard.com/CommentView,guid,1beedf7e-597c-4633-8c32-5942a24ce141.aspx</comments>
      <category>.Net</category>
      <category>JavaScript</category>
      <category>Technology and Friends</category>
      <category>Video</category>
    </item>
    <item>
      <trackback:ping>http://www.davidgiard.com/Trackback.aspx?guid=2f720a44-9bac-445f-aeb8-b7347b5f9cbb</trackback:ping>
      <pingback:server>http://www.davidgiard.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.davidgiard.com/PermaLink,guid,2f720a44-9bac-445f-aeb8-b7347b5f9cbb.aspx</pingback:target>
      <dc:creator>David Giard</dc:creator>
      <wfw:comment>http://www.davidgiard.com/CommentView,guid,2f720a44-9bac-445f-aeb8-b7347b5f9cbb.aspx</wfw:comment>
      <wfw:commentRss>http://www.davidgiard.com/SyndicationService.asmx/GetEntryCommentsRss?guid=2f720a44-9bac-445f-aeb8-b7347b5f9cbb</wfw:commentRss>
      <slash:comments>4</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <img border="0" src="http://www.davidgiard.com/content/binary/TechnologyAndFriends.gif" />
        </p>
        <p>
          <strong>Episode 162</strong>
        </p>
        <p>
          <a href="http://technologyandfriends.com/archive/2011/06/27/tf162.aspx" target="_blank">Mike
Amundsen on node.js</a>
        </p>
        <img width="0" height="0" src="http://www.davidgiard.com/aggbug.ashx?id=2f720a44-9bac-445f-aeb8-b7347b5f9cbb" />
      </body>
      <title>Mike Amundsen on node.js</title>
      <guid isPermaLink="false">http://www.davidgiard.com/PermaLink,guid,2f720a44-9bac-445f-aeb8-b7347b5f9cbb.aspx</guid>
      <link>http://www.davidgiard.com/2011/06/27/MikeAmundsenOnNodejs.aspx</link>
      <pubDate>Mon, 27 Jun 2011 18:25:37 GMT</pubDate>
      <description>&lt;p&gt;
&lt;img border="0" src="http://www.davidgiard.com/content/binary/TechnologyAndFriends.gif" /&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Episode 162&lt;/strong&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://technologyandfriends.com/archive/2011/06/27/tf162.aspx" target="_blank"&gt;Mike
Amundsen on node.js&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.davidgiard.com/aggbug.ashx?id=2f720a44-9bac-445f-aeb8-b7347b5f9cbb" /&gt;</description>
      <comments>http://www.davidgiard.com/CommentView,guid,2f720a44-9bac-445f-aeb8-b7347b5f9cbb.aspx</comments>
      <category>JavaScript</category>
      <category>Technology and Friends</category>
      <category>Video</category>
    </item>
  </channel>
</rss>