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!

Advertisements

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.

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!

 

 

 

 

 

 

 

 

 

 

 

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!

 

Another Stab at Bootstrap

I can’t say that Bootstrap and I get along very well. I’m slowly coming to slight understanding of it but it feels like one step forward and two steps back. I just get a hint of understanding, that penny dropping moment then, when I go to repeat the action in a different site, it goes haywire…After my problem with the nav bar (turns out I was using the newer version of Bootstrap which wasn’t supported by the code I was cutting and pasting) I was fearful of not knowing enough before moving on. So I built another portfolio site for the sheer hell of it. I’m fond of no.1 as it’s my first but the second one looks more professional. The only thing I didn’t manage to do was get it to smooth scroll but I’ve given up since it’s a JavaScript thing and I’m learning this next. Screenshot of my newest creation below. Zero responsivity. No building from mobile up. But it’s my baby, as imperfect as it is…4thsitesnip

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.

Bootstrap!

Today was Bootstrap day. Bootstrap is like a ready made css file that you can upload to your html. It has lots of pre-made classes for you to choose from. I didn’t find it much easier than doing long-form css but given both are difficult for me right now, that’s probably not a true reflection of what it can do.

I made an other version of my 1st website using Bootstrap this time. I managed to centre text plus use rows and columns to help with spacing. Still nothing to write home about but I’m glad I did it for the practice. Again, you’re missing out on the glorious animated gif and can’t make out the alternative to Lorem Ipsum- Bacon Ipsum that I used. Google them!

Bacon and eggs website snip

 

All about meeee!

I promised to let you know a bit about me so here goes: I’m 36 and come from Scotland. I’m not currently working due to severe depression. I’m hoping that, just maybe, this web development lark might be a new start.

I love the cinema and art and design. I used to like learning German, quilting and traveling but my brain isn’t letting me enjoy them right now.

If you have any questions, leave it in the comments box below!