Biking Home

Biking Home

Biking Home is one of my favourite songs of all time, and it is from the Soundtrack of one of my absolutely most beloved movies, the Whale Rider.

The Whale Rider stands for everything I love. 

It stands for nature. It stands for being true to who you are. It stands for following your destiny. 

It is also about a woman who makes it in a role that is meant to be for a man, defying all odds and expectations. This movie has been such a major part of the healing I have gone through in my life. In fact that's ultimately where Software Engineering emerged in my life - it came at the end of a long, long healing process. Ultimately, it couldn't have arrived more perfectly.


The poster for the movie 'The Whale Rider'.

Right... back onto the JavaScript Stuff. And the Conditional Statements.

Ternary Operators

Right, so today I learned ternary operators. 

I think I have just forgotten everything.

let superCoolName = 'Susanna';

superCoolName === 'Susanna' ? console.log("Your name is super cool!") : console.log("Your name is not so cool");

Another way of doing this is:

As opposed to writing

let havingAGreatDay = true;

if (havingAGreatDay) {
  console.log("Yay! You're having a great day! That is awesome.");
} else {
  console.log("Oh no! What's wrong? What can we do to make your day better?");
}

You can instead write:

havingAGreatDay ? console.log("Yay! You're having a great day! That is awesome.") : console.log("Oh no! What's wrong? What can we do to make your day better?");

I love this so so much! I love this SO much! This is what I love about programming - things that make sense to me.

One more example of the latter:

Instead of

let dumbQuestions = false;

if (dumbQuestions) {
  console.log("There are no dumb questions!");
} else {
  console.log("Okay, that question was kind of dumb.");
}

Then:

dumbQuestions ? console.log("There are no dumb questions!") : console.log("Okay, that question was kind of dumb");

Hmmm, I think I GET IT!!! woohoo

Else If Statements

I have done these before in Python so it's all Gucci. I'm just lacking confidence in my syntax but I seem to be getting it all write. Quick example

Lana Del Rey songs (i.e. the ones that I listen to on repeat all the time).

let favoriteLanaSong = 'Yosemite';

if (favoriteLanaSong === 'Yosemite) {
  console.log("Play Yosemite!");
} else if (favoriteLanaSong === 'California') {
  console.log("Play California!");
} else if (favoriteLanaSong === 'Architecture') {
  console.log("Play Architecture!");
} else if (favoriteLanaSong === 'Old Money') {
  console.log("Play Old Money!");
} else {
  console.log("Just play me any Lana song! They're all the best, after all!");
}

Switch Statements

Oh my goodness me I have seen these before!!!! I have the BIGGEST sense of deja-vu with these!!! Maybe in another lifetime? I have seen these before!!!! But how!!!! But HOW?

I'm sorry, but I am TOO TIRED to write about these right now ๐Ÿ˜‚๐Ÿ˜‚sorry! But at least that means that I have learned a lot today.

Maybe I will write about them tomorrow?

FINE!!! I'll do this now.

So suppose if I have loads of values (kind of like I did above) then this is a better way to do this.

So the above example could be written:

let favoriteLanaSong = 'Yosemite';

switch(favoriteLanaSong) {
  case 'Yosemite':
    console.log("Play Yosemite!");
    break;
  case 'California':
    console.log("Play California!");
    break;
  case 'Architecture':
    console.log("Play Architecture!");
    break;
  case 'Old Money':
    console.log("Play Old Money!);
    break;
  default:
    console.log("Just play me any Lana song! They're all the best, after all!");
}

Comparison Operators and Logical Operators

Just as a recap:

Comparison operators are <, >, <=, >=. ===, and !==

Logical operators are (my faves!) &&, ||, and !

Final Thoughts of This Evening

I just want to finish off by saying that code can mean so much to people in terms of empowering themselves and overcoming difficult things.

It means so much to me to code. I am overcoming so much when I do this. I have healed so much by doing this.

Comments

  1. Here's an two extra operators:

    One more comparison operator `==` which is an equality check, like `===` however you can think of `==` as a loose equality check and `===` as a strict equality check. So what does that mean? Well here's an example: '1' == 1 would be true since they're both one however '1' === 1 would be false because one is a string and the other is a number. It's highly recommended to not use `==` and always use `===` for the above reason but it's worth knowing it exists.

    ReplyDelete
  2. Wow, Adam, that is absolutely fascinating!!! Thank you for sharing this! Thank you!

    And as always thanks eternally for your support on my blog and on all platforms it really means so much to me, it means the whole wide world!

    ReplyDelete

Post a Comment

Popular posts from this blog

Hello World

Yosemite

Two Lines of Thought, Makes Me Wonder What I'm Missing