Blog one-month anniversary

Dearest readers,

Beyond my skeptical expectations, it’s been over a month now and I’m still both doing FCC and blogging. I have to admit to having a week off after finishing JS but I got annoyed at myself for abandoning the opportunities that becoming a developer could bring I’ve dragged myself back to it. I’m both excited and very unsure of the next section which is basic algorithm challenges. This is where you need to start thinking like a programmer.  Which I’m looking forward to. But will also require me to be able to recall or, more importantly, understand the previous lessons… I’ll keep you updated on how each challenge goes, if or when I get them completed. Perhaps with the odd frustrated winge along the way. No. 1 is called “Reverse a String”.

Advertisements

Finally, understanding!

Hello, folks.

Been in a JavaScript personal hell what little self-confidence disappeared and I’ve flopped around like a fish out of water. However, I have, finally, managed to fully understand that Profile Lookup FCC challenge. So, here goes for a walk through:

We start out with x initialised at 0, moving as far as the end of the contacts list and moving on one at a time. Now, if the value of firstNames is a match, and the property value also has a match, you return both the first name and the property.

But if only the property has a match, you return “No such contact”. Then finally, if there’s only a firstName match, you return, “No such property”.

All of this is very similar to the original instructions which I completely over thought. I also didn’t allow myself to thoroughly go through my notes which would have helped a lot. So, while I’m still the odd bit or bob off trying again without notes, I get what my mistakes are and why they’re wrong. So that’s a wee bit of progress.

Next up is a session on Object Oriented and Functional Programming. Then a big, big 50 hour chunk of basic algorithms in  long list of problems to solve. I’m looking forward to the new challenges but I’m concerned I won’t manage them. I feel like I’m hitting a natural boulder of ability that I’m not going to get beyond. I really need to get building another website so I don’t forget those basic skills while I try to obtain a different set of basic skills.

Do you ever doubt you’ll reach your big goal? Do you have any mental tricks to get past those doubts?

Back on the horse

Well, I decided to get back on Free Code Camp a bit early as I’ve been getting disillusioned with with my text book- Sam’s HTML, CSS and JavaScript. It had started out well and I felt I was getting extra concepts that with FCC but then I started typing out the exercises and realised that there were quite a few concepts that hadn’t yet been explained, or not fully enough in order for me to properly understand what was going on.

So I’ve restarted JavaScript on FCC from the beginning. I ought to get back where I was tomorrow. I can’t totally blame my book though. I’m struggling to retain anything at the moment but maybe that’s just because JS is hard if you haven’t done any coding before at all…or maybe that’s just an excuse and I need to work smarter.

I’ve just rejoined the gym and been going through posts on Pinterest for some motivation.  My favourite is “your speed doesn’t matter. Forward is forward.” Make it so.

A penny drops

Today’s efforts have elucidated a few issues for me. Firstly, arrays. For whatever reason, I hadn’t grasped that they’re packets of information. I was viewing them as sequences of numbers. Rather than seeing the numbers within an array and the instructions relating to that number specifically,  instead its position within the array. So that’s a minor breakthrough for me.

Secondly, the evil FCC exercise that had been eluding me has become 2/3rds understandable. I now understand that:

variable x is initialised at 0 value, runs until the end of array called contacts and involves moving on 1 position after each loop.

Then, if during the loop, a first name matches a first name AND if property matches with a property, then you return the values of x(first name) and the property.

If it takes a subsequent loop and it finds a match just for a first name it returns, “No such property” and if it loops again and doesn’t find anything then “No such contact” is returned.

What I still don’t understand is the useage of ‘.firstName’ and ‘.hasOwnProperty’. I mean, I get what they stand for but I don’t know the use of the dots, nor where the hasOwnProperty bit arrived from. At least I’m not too worried and have a bit of faith that I’ll come across this in my textbook before it’s time to get back to FCC on Sunday.

Meantime, I’m going to watch the Harvard CS50 computing course videos on youtube. I’ve heard it’s really good at explaining how to think like a programmer. Ciao for now!

DUM, DUM, DOM!

Back on the books tonight and the rest of the DOM chapter. It was about using the Document Object Model to make buttons to move your browser back and forwards history-wise, make text disappear and reappear and also add text typed into a box to show further up the page. ‘Dynamically’ as they say. I’ve found the explanations really hard to visualise. While typing out the examples does certainly help, there’s tons of code that I can only hope I’m only meant to have a vague knowledge of rather than actually know off by heart (I hope). Tomorrow should bring variables, strings and arrays so hopefully more familiar territory.

Diverted

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.

A little extra homework

First off, thanks very much to my new friend, Codeinfig, for helping me to understand the problem I was having regarding the function of [i] in the example array. If you want to see his (presumably, although not necessarily?) explanation, check out my previous post and look in the comments section.

I’m obviously not ready to carry on with Free Code Camp’s JavaScript unit until I have a better grasp. So I’m circling back on myself (like ‘ spiral learning’ if you’re a teacher) so I have a better grounding before I get back on the horse.

I’m using ‘Sams Teach Yourself HTML, CSS and JavaScript’ (second edition). I’d found a copy in my local library and found it so good I bought a copy off ebay.  I’ve just finished chapter 4- Understanding JavaScript where it gets you to build a very, very basic clock.  I’m now looking at chapter 14 which is Getting Started with JavaScript Programming. Upto Chapter 18 seems to run parallel or a little ahead of where I am/was with FCC. So, presuming one chapter a day with Mondays being an enforced rest day due to other commitments, I ought to be back with FCC in a week. Allons-y!

 

 

 

 

 

 

 

 

 

 

 

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++) {

console.log(arr[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!