The Tunnel

The Tunnel

OH MY GOD. 'The Tunnel' is a song by French For Rabbits and I am so in love with it, oh my god, oh my god, oh my god. There were SO MANY CONTENDERS for today's blog post title but at a few minutes before EOD I heard this one and just KNEW.

"There's a light at the end of the tunnel, I know".

***

"There's a light at the end
Of the tunnel we're in
And it glows all the night
From a mile I can see it
Do you see it too, where you are?
It's the same bright stars".

***

"Dream something,
Even if you don't believe in it!
Dream something, 
Even if you cannot see it!".

I actually think that I might cry. 

I have never SEEN such beautiful song lyrics! 

It reminds me of 2 things:

- One of my favourite quotes of all time: "There is no light at the end of the tunnel. You are the light". 

- And a story from one of my favourite Buddhist Monks, Ajahn Brahm - where he says the suffering and the overcoming of it allows us to take someone who has been through the same thing as us by the hand and say to them "There's light at the end of the tunnel", and we get to really mean it because we have been through this thing ourselves. There are a lot of people whose hands I want to hold these days... There are a lot of people who I want to tell that there are certain types of things you can get through, and still have the most beautiful life in the world afterwards.

And so if you're reading this, please believe me... there's a light at the end of the tunnel - but the catch is, it's so bright, you would never BELIEVE how bright it actually is 🤗 And I love it, and I love everything.


A Quick Note On for Loops

Just to note that where a typical for loop might look like this:

for (let counter = 0; counter < 4; counter++) {
  console.log(counter);
}

Then the 3 things inside of the first brackets are not called parameters. They are called expressions.

They are called expressions

Thank you!!!

Looping in Reverse

So as far as I can understand from it, looping in reverse (at least in this context), is just like a for loop, but the counter is counting downwards, not up. 

Pretty easy huh?

Looping through Arrays

This is a lot. Here's what the course says:

"To loop through each element in an array, a for loop should use the array's .length property in its condition". 

Okay wow so the course has an amazing example and I would like to type this out. 

In celebration of Brooke Bentham's new EP, Caring, let's adapt it to her songs:

const caring = ['Over and over', 'Almost Heaven', 'Let go', 'Stop'] 

for (let counter = 0; counter < caring.length; counter++){
    console.log(caring[counter]);
}

(I know I should probably be using i instead of counter but it is making it easier to grasp things for now and for me to understand them). 

Yay - I tested out and this worked!!! 

The output is - as expected - :

Over and over
Almost Heaven
Let go
Stop

My course something else that's pretty interesting although I don't really fully get what it means. 

"With for loops, it's easier for us to work with elements in arrays". 

Not 2 million percent sure what this means but yeah, thanks, thank you.

Catching out myself on my little mistake

I forgot/keep forgetting to put the let in in the for loop. It goes:

    • At the beginning of the first expression, or the initialisation, and right before the counter/ i
      • Right after the for and then the bracket

Nested Loops

I watched a Bro Code video on these as I was feeling a bit overwhelmed. Anything with the word Bro in it is always going to be my first preference. 

And he said: 

"So that's how a nested loop works - it's a loop inside of another loop". 

Or here's another quote from my JavaScript book:

"As you can see, the inner loop runs all the way through for every step of the outer loop.

Once the inner loop has run all the way through, the variables for the outer loop are updated and it runs the inner loop all the way through again." 

What the course says

What my manager and others keep telling me is that I need to focus on my course. 

So I need to focus as much as possible on my course, please. So what does it say?

"One use for a nested for loop is to compare the elements in two arrays".  

The Example Codecademy Gave Me In The Course

The example Codecademy gave me - well except I'm still confused omg omg omg.

const array1 = [6, 19, 20];
const array2 = [19, 81, 2];
for (let i = 0; i < array1.length; i++)
{
    for (let j = 0; j < array2.length j++) {
        if (array1[i] === array2[j]) {
            console.log('Both arrays have the number: ' + yourArray[j])
        }
    }
}

The console.log() will only get run as a part of the inner loop, because it is quite literally situated right inside of the inner loop. 

Chat GPT to the rescue

I have been BANNED from using ChatGPT to find answers to things - but I am still allowed to use it to read code. So I got it to break down the above example for me, as I was going insane. 

LUCKILY IT MADE IT CLICK FOR ME and IT MADE ME JUST UNDERSTAND NESTED LOOPS JUST IN GENERAL. So, maybe, when it comes to reading code examples, then Chat GPT is okay, just like my boss has said.

While Loops

Running as usual to the safety, the comfort and the solace of my JavaScript book. What it says is: 

"[A while loop] will repeatedly run a block of code while a certain condition is true".

But here is what my course said, actually: 

(coming back to it as always)

Well, actually it's the Codecademy loops documentation - but never mind. It says:

"The while loop creates a loop that is executed as long as a specified condition evaluates to true. The loop will continue to run until the condition evaluates to false."

The straight away, first thing, that I notice:

Is that whereas with for loops you don't have to declare the variable outside of the expressions within the loop, you do have to declare the variable for a while loop before it starts. 

Here's a good example from the MDN:

let n = 0; 

while (n <3) {
  n++;
}

console.log(n);
// Expected output: 3

Or here is one from Codecademy:

let i = 0;

while (i < 5) {
  console.log(i);
  i++;
}

The output would be:

0
1
2
3
4

Okay, more of these while loops tomorrow, please!

Spotlight On One More Song: Question It All

"Question It All" is a song by Lucy Rose, and when I listen to it, I can hear EVERYTHING. I can hear EVERYTHING. I can hear it ALL. I can hear the forests and the hills that I love so much back at home in Luxembourg. 

I can hear the valleys and the hills that I climbed, dreaming, dreaming, dreaming of this. Dreaming of this moment. This moment when what? When I would manifest my destiny. 

Because I always knew that it was coming. My destiny.

I always knew that it was coming. I just didn't know what it was, and when.




Comments

Popular posts from this blog

Hello World

Yosemite

Where To Hide A Star