Javascript cribsheetery

So to declare either variables OR functions (and I assume, later, objects? unless it turns out they’re the same – they might be the same), it begins with var variableName = and if it’s a simple variable, it behaves predictably, and moves on to var variableName = (5 * 2). If it’s a function, this entire lovely curly brace structure needs to be set up:

var functionName = function (parameter) {
    console.log(parameter * 2);
};

and then to call:

functionName(5)

where 5 is the parameter of the function functionName.

Ok. Rock and roll. Movin’.

Lesson 38

In this exercise, we play with splitting, adding to lists, & the join function, referred to in this stack overflow post as the inverse of the split function.

split cuts up any old text string, like mary had a little lamb and turns it into a formal list, like ["mary", "had", "a", "little", "lamb"], with each word made into an indexable (numerically anyway) item in a list, via the format of stringofwords.split(" "). I’m not toooootally square on the quotes in the formatting of the use of split, but I can punch it in well enough til I grok it fully.

join depends on the same structure of listofitems.join(" ") to de-string-ify it. Handy!

There’s a bit also with, hmm, how do you call it, positional list comprehension, maybe? For example in the previous given list, the ["mary", "had", "a", "little"} et cetera, position 0 is the very first one, mary, where position -1 is the very last, little.

This was a good one! I think the exercises will stay challenging through the next thirteen : )

Lesson 28

Hoo-woo-woo-wow, Lesson 28 was a zipper, but I imagine that is only because I took Discrete Mathematics about a year ago, in which boolean logic was beaten into us : )

I thought this truth determination was especially funny to find. Can you find the correct truth value?
"chunky" == "bacon" and not (3 == 4 or 3 == 3)

I got them all right! Moving on, breakneck pace my friends! But really, I want to get back, so badly, to “copy this in & solve a problem.” I looked ahead a bit & I think the next one is like that. Oooooh I hope!

Lesson 26

AHH.  Feels good to be back to ordinary python (though I now have much more planned for heroku/django!).  Today I wanted to punch out a quick lesson since it’s been a few weeks for a Learn Python the Hard Way, and I want to maybe finish the book by the end of the year.  Here’s exercise 26, a debugging exercise. Excellent. *cracks fingers* Ok! First, I copied in the required “code” from here into nano & immediately set to correcting all the tiny errors, like missing parentheses, spelling errors (not that those matter too much in this exercise but pedantic habits die hard), and inconsistencies with function naming/calling. I knocked this out in about fifteen minutes. Exciting!! I should do another, even though it’s thanksgiving eve & that bathroom isn’t going to clean itself 🙂 ok but yeah just one more for real, this didn’t quite scratch the itch! and then I’ll get to the bathroom, jeez DAD LAY OFF

Edit: OH MY GOD THE NEXT EXERCISE IS TRUTH TABLES! HOORAY!!

seriously, I love truth tables.

Lessons 22 and 23

Ok! These were sorta boring! 22 said “go back over everything and make sure you know it,” essentially, and because I am impatient, I went through all the previous lessons in around an hour, surprised at how much I have actually absorbed. Then I moved speed-quick over to the 23rd exercise, which says to look up code and see if you can understand it, so I did a bit of that, and now I am again quite anxious to get back to regular lessons. : )