Begin to Code with JavaScript on Taskmaster

Taskmaster is a super TV program. The Taskmaster gives, er, tasks to competitors. The tasks are always interesting and the real joy of the program is watching how the competitors respond to each one.

In the show last night (season 12 episode 8) at the very end they played a game that they called “Pop Up”. Everyone sits down and then the last person to stand up before a particular event occurs (they had a pop-up toaster, jack in the box and bursting balloon) wins. It was great fun to watch.

If you want to have a go at this at home you can use a web page that I created as an example program for my book Begin to Code with JavaScript. I called it “Nerves of steel” and it works in a very similar way. The page starts a random timer. The last player to sit down before the timer expires wins. You can play it here.

If you enjoyed that you can then you can graduate to High and Low, where players try to guess whether the next random number will be higher or lower than the previous one. Guess wrong and you are out, last person in wins. You can play that here

.. and you can buy the book here:

Editing with lovely pictures

kitchen.jpg

I’ve just received a set of chapters for the final editing pass for my Begin to Code with JavaScript book. This is the point that I get to see what the artists have come up with for the illustrations at the start of each chapter. As usual, I’m completely knocked out by the quality.

I reckon that the book is a good buy just for the pictures. You can pre-order it here :)

Dice or Die: the eternal question

dice1.jpg

One of the questions that popped up when editing “Begin to Code with JavaScript” (pre-order it here) is “die vs dice”. One of the example programs is making a program that delivers a random value in the range 1-6. In other words a die (die being the singular of dice). However, in the text I call it a “dice”. I know this is wrong, but I’m determined to avoid having a section with the title “How to make a computer die”. This makes sense to me, I’m always happy to trade a bit of credibility (people might think I don’t know it’s really called a die) for a lot of understanding.

Begin to Code with JavaScript Final Edit Pass

begin to code image.jpg

My efforts with my programming are taking a back seat for a little while as we are starting the final edit pass for “Begin to Code with JavaScript”, which is due to be in the shops later this year (but you can order one now if you like..)This is the point where I get to see all the splendid artwork that’s been added to the text, like the picture above. So far the text is looking good. Just another 11 chapters to go through.

I say tomato.png you say Tomato.png

killer tomato.png

Sometimes, way back in the past, software writers set massive traps that we still fall into today. Like when someone at Microsoft wanted to make MS-DOS seem different to Unix so they used backslash “\” for filename separators rather than forward slash “/”. Or that other time, when someone else (or maybe the same person - who knows) thought it might be a wizard wheeze to make MS-DOS not care about the case of filenames so that Fred and fred were regarded as the same file.

This piece of genius still haunts us today. For example, when you put the web pages that you tested on your PC up onto GitHub and then find that they don’t work because you’ve said “tomato.png” in the code and the file is called “Tomato.png”.

Now, we’ll gloss over the stupidity that caused the file to be called “Tomato.png” in the first place - mainly because that is my stupidity. Let’s focus on how hard it is to fix. If you rename the file on your PC (which is hard enough because you can’t just rename Tomato to tomato - you have to go Tomato->temp->tomato) GitHub doesn’t see this change in filename name as a change in your project and so it won’t push the changes into the server. I could change the filename to “Tomato.png” in the program code, but all my other files start with a lower case letter and I’m loth to be inconsistent. I do have some pride left.

In the end I’ve fixed this by changing the name of the image file to “redtomato.png” which does reflect a change and also makes the game futureproof in that if I fancy adding some blue tomatoes later I now have a naming convention I can use.

If you’re not sure why I want to have tomatoes in my game take a look here. See what kind of high score you can get. My maximum so far is 740.

Begin to Code with JavaScript is written

begin to code with JavaScript.png

It’s done! Yay! I’ve finished writing all the chapters of Begin to Code with JavaScript. I’ve been turning out a chapter every two weeks since early April. It’s been great fun and a wonderful distraction from the end of the world as we know it.

Of course the book is by no means finished. It now needs to be made right, which is what we do in the editing process. Since I’m ever the optimist though, and I’d appreciate feedback, you can read the draft version of the text here. I’m going to spend some time over the next few weeks catching up with the podcasts for the book, which you can find here.

Chapter 10 of Begin to Code with JavaScript now available

begin to code with JavaScript.png

I’ve just uploaded Chapter 10 of Begin to Code with JavaScript. It tells you all about building a cool class hierarchy in JavaScript. You can find it, along with all the other chapters, here. You won’t be able to hear it for a while though I’m afraid. It turns out that writing deadlines are more important than reading deadlines.

Killing your favourite children

boats.png

Ages ago I went to a creative writing seminar. It was really interesting. One of the points that they made was that sometimes when writing you have to “kill your favourite child”. What they meant was that you might have a lovely chunk of prose that you are very proud of, but it just don’t quite fit into the context of the piece you are writing. There are two things you can do. Spend ages trying to make your wonderful words fit and fail. Or just get rid of them and move on.

I was reminded of this today when I was writing Chapter 9 of Begin to Code with JavaScript. I’m talking about software objects and I’d written a lovely piece of code that used a schema to create objects and properties on the fly. You can do this kind of thing in JavaScript and its awesome. However, I couldn’t make the example fit into the rest of the chapter. I spent far too long trying to create a solid context, wrote a few pages and then stood back from the piece, took a long hard look at it and then threw the whole thing away. What is left is much better, and of course I’ve not completely discarded the stuff. I never throw anything away.

Sometimes you have to ditch something that you really like because of your loyalty to the final result.

New Begin to Code with JavaScript Podcasts Available

Do you want to learn JavaScript the fun and painless way? Then go forward 200 years into the future when they can plug something straight into your head. For now though, you could do worse than investigate the Begin to Code with JavaScript podcasts for my new book I’ve just uploaded. They are packed with jokes, music, song, dance and misleading product descriptions.

You can get a draft of the book for free and watch screencasts where I code things live that nearly always work. Search Apple Podcasts for “begin to code with JavaScript” or listen fresh from the web at https://www.robmiles.com/jspodcast

Fixing the width of an HTML element

fixed width ice cream sales.png

If you want to make an element input with fixed with labels you can do it by adding this to the style for the element:

.menuLabel {
display:inline-block;
width:12em;
margin: 10px;
}

The width bit sets the width of the label and the inline-block setting for display makes sure that the input field lines up properly. You can use it to make other things line up too.