I was meant to be doing more on JavaScript this evening- which I did for a bit- until I developed the irrational notion that I had to jazz up my clock project beyond the bit I copied  learned from the book. So, behold the wonderous borders. Be amazed at the use of a box shadow and blinded by central alignment of my text here. It took me 2 bloody hours of going round in circles losing my alignments and chasing the rectangles around. It won’t win any design awards but it’s as done as I can think to make it right now. I did also learn about wrappers/containers and how to overlap text on a shape so it was a good exercise in itself. However. No more excuses and back to DOMs tomorrow.

Hitting a brick wall

In going through the FCC challenges, there have been times I’ve given in to looking at a hint after a few hours of no progress but I’ve been able to figure out the working and I’ve been able to move on. I might be being somewhat over-dramatic but I think I’ve found my nemesis and it’s got me in a choke hold and is pummeling my face…Nesting for loops.

I was doing okay with iterating odd/even numbers as well as counting backwards. But pop an array in there and I’ve got a problem. The key thing I don’t understand which may, or may not, be the key to my problem is the [i] in the following:

var arr=(10,9,8,7,6)

for (var i=0; i <arr.length;i++) {



I get that the variable is the top array. Then the loop initialises with the value 0. Then the condition is that it will continue cycling as for the length of the array as its maximum while adding 1 more  every loop. Now, it’s meant to output each part of said array but I don’t really understand the relation between the array and that final [i]. I definitely need to go back a couple of lessons and thrash it out. Nesting for loops?! I’m coming for you!!!!!! p.s if you can explain it to me, you have a friend for life!

Switching causing violent twitching!

The basic JavaScript section continues slowly. It started off with simple addition/subtraction etc. But now has gone into the logic side of things using ‘If’ ‘else’ statements. Now, that’s not too hard if you remember where to put your brackets and semi-colons. Then came a more involved task that involved using a switch statement to create a blackjack decision making tool. These are (slightly) simplified version of if/else which is less wordy but does the same job.  However, the task didn’t specifically say that you needed to use a switch statement. As you needed to go back through the unit to the more basic concepts (pre-switch) it didn’t occur to me that there’d be a problem doing it long-hand.

However, there seems to be a divide between those who successfully managed the job with switch and those who tried to do it otherwise and failed miserably, like myself. For reference/in case you’re interested, here’s the solution.  I tried to redo the task myself using Switch before I totally succumbed to the full answer and I wasn’t using the ++ or — operators. I had understood the task but not the ‘how to’ although the answer does make complete sense. I can only hope that this is a minor hiccup…

This is the answer:

function cc(card) switch(card){ case 2: case 3: case 4: case 5: case 6: count++; break; case 10: case “J”: case “Q”: case “K”: case “A”: count–; break; } if (count > 0){ return count + ” Bet”; } else { return count + ” Hold”; }

Look how tiny and pretty it is!


Oh dear…

It’s taken me less than a week to hit my first bump (although it feels like a mountain) in the road. For FCC, I’m tasked with creating a first portfolio for sharing your other projects with.  The format is reasonably straightforward- a scrolling site with sections about you, your portfolio and contact details.  But I spent all-day repeatedly scrubbing out the coding for  my blasted navigation bar. It wouldn’t stay put, text wouldn’t line up, one thing got sorted but made another thing worse. Most frustratingly, the code is all up on the internet- you just have to pick the right sections to copy and paste but even then I was getting into a right mess. I seem to have reached a sort of compromise with it. I’m going to leave the navbar alone for a few days while I sort out my portfolio and contact sections out. I’ll let you know how it goes.