This page is part of a static HTML representation of TriTarget.org at https://tritarget.org

Musings of a Coder

25th March 2016 at 6:48am

Lately I've had some insperation to try my hand at some coding homework. I was introduced to a site called The Codecademy. This site teaches people how to program. They started with JavaScript and recently added HTML and CSS.

Here are a two I enjoyed playing with:

Black Jack

One of the big challenges was to make a Black Jack game. I was a little carried away and spent the time subitting this code as my final version.

Update: Upgraded to use promises and no more confirm().

BlackJack in JavaScript on jsbin.com

Number Crunching

While I was ridding home on a train I got the inspiration to wonder just how many computer bits it took to represent a googol (one followed by 100 zeros):

10, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000

Because of the size of this value there is no computer that could do the math with basic binary arithmetic. Instead you have to rely on the kindergarten method of long hand addition.

So I wrote a program to do this in JavaScript. Check it out:

Number crunching example on jsbin.com

Suffice it to say, it take 334 bits to represent a googol.

Discuss this article