I Am Inexhaustible

I Am Inexhaustible

I Am Inexhaustible 

I am inexhaustible. My passion is inexhaustible. My enthusiasm is inexhaustible. What I have to offer to the world is inexhaustible. My love is inexhaustible. My kindness is inexhaustible. My caring is inexhaustible.

My passion is inexhaustible. My love for what I do is inexhaustible. My happiness at being a Software Engineer is inexhaustible. My love for my job is inexhaustible. My excitement is inexhaustible. My enthusiasm is inexhaustible. My love is inexhaustible. My talent is inexhaustible.

My power is inexhaustible. My power is inexhaustible. My power is inexhaustible.

My gratitude to the universe, for allowing me to be on this path and to follow my destiny, is inexhaustible.

And who I am is who you are, and it is all the same, really.

My passion is inexhaustible. My enthusiasm is inexhaustible. My love is inexhaustible. My love for what I do is inexhaustible.

We are all inexhaustible. You and I are inexhaustible. We are inexhaustible. 

Now Back Onto The Loops

But first, here's a picture of the forest near my house in Luxembourg. 


I like to go walking here and it's just SO BEAUTIFUL.

do... while Statements

So I did these yesterday and I did them way too fast and I would like to go over them one more time please - thanks!!! But the premise is simple: 

  • A do...while loop does something ONCE - this is GUARANTEED - and this is the DO BIT.
    • THEN, AFTER IT HAS DONE THE LOOP ONCE - IT CHECKS THE CONDITION AT THE END. 
      • OR, IT EVALUATES IT!!! 
    • THEN, IF THE CONDITION IS TRUE THEN IT REPEATS THE LOOP
      • FOR HOWEVER MANY TIMES
        • FOR HOWEVER LONG IT IS THAT THE CONDITION IS TRUE. 
  • Wow, thank you so, so much! Wow, this is amazing! Thank you!!! 
    • At this point I am just thanking whoever it was that invented this -
    • this is SO COOL!

Sample syntax of a do... while statement 

let stringCounter = ' ';

let i = 0;

do {
  stringCounter = stringCounter + i;
  i++;
}while ( i < 5);

console.log(stringCounter)

The output of this, as I expected it to be, is 01234, although I don't understand why it prints on a line and with no spaces, as opposed to with other loops, which often seem to print one element per line, one by one.

Quoting Chat GPT

Now, we all know that I have been BANNED from using Chat GPT - at least when it comes to finding solutions to coding problems. But I haven't been banned from using it for analysing code - in fact that's what my boss told me it's good for (at my level anyway).

Chat GPT has some surprisingly good quotes about do...while loops:

Chat says about a do...while loop:

"This type of loop will always execute the code block at least once, and then repeat it as long as the condition in the 'while' statement IS TRUE".

Some more examples of do... while loops:

Someone on discord gave me this code:

const examples = [];
do {
  const newExample = await askForNewExample();
  if (newExample) {
    examples.push(newExample);
  }
while (examples.length < 6);

I'm not 100% sure if it actually works, BUT it is a nice example of what a do...while loop could look like/and do in some other shape/or form. 

OMG I am such a mug... here is the example from my course

Because, let's say, this was a pretty good one, actually... and it worked.

const cupsOfSugarNeeded = 5;

let cupsAdded = 0;

do {
  cupsAdded++;
  console.log(cupsAdded);
} while (cupsAdded < cupsOfSugarNeeded);

I love this example, it's so cuuuuuuuuuuuuuuuuuuuuute! It's all about baking a cake.

And what the course said was that they love cakes and they have a sweet tooth and that they wanted to add in a cup of sugar NO MATTER WHAT omg (... that is the do... part in the loop). 

And okay maybe they didn't say that they loved cakes... maybe I just added that bit in. 

The break keyword

Here is the example of the break keyword from the Codecademy course because my brain is too tired to come up with anything else.

for (let i = 0; i < 99; i++) {
  if (i < 2) {
    break;
  }
  console.log('Banana.');
}

console.log('Orange you glad I broke out the loop!');

What the code is actually doing here:

Two parts of the code are inside of the actual for loop. - The bit that checks if i <2 and then breaks if it does - and then the bit that console.log()s 'Banana'. 

Basically, if the if condition is true, then the for loop breaks.

Looping Through Arrays

Okay so I just wanted to go over this one again because it was the one thing I didn't feel like I had quite grasped when I went 

Ahh I see. So the main thing here to remember - as always - is the .length property. 

I got this wrong an an example that I sent to by boss on Monday, but we went over it together, so I really should have this clear in my head by now. 💮

The for...of Loop

"As well as with arrays, for...of loops also work with strings, sets, and other array-like objects.
              
Therefore, you should opt for a standard for loop if you need to access the indices or need finer control to determine what elements you want to loop over."

*

"The for...of loop does not change in structure regardless of the iterable object used". 

I.e. the for...of loop is the same regardless of whether it is used for an array or a string, for example.

*

"for...of has the advantage of setting up most of your loop parameters for you, but sometimes it is necessary to reclaim some control of how iteration is managed. One way of doing this is using JS's break and continue statements". 

The break and continue statements

Again, we're still in for...of loops here.

break

Th break statement stops the loop right there an then if the loop encounters a certain value. This "can be used to jump out of a loop". 

Example:

const greatSongs = ['Stairway To Heaven', 'Question It All', 'Beginning To See The Light', 'There's A Light'];

for (const song of greatSongs) {
  if (song === 'Beginning To See The Light') {
    break;
  }
  console.log(song);
}

The output will be:

Stairway To Heaven
Question It All

Makes sense?

continue

The continue statement essentially skips "one iteration of the loop". One iteration of the loop, one iteration of the loop.

So an example is:

const thingsILove = ['Software Engineering', 'Coding', 'JavaScript', 'Singing', 'Codecademy'];

for (const love of thingsILove) {
  if (love === 'Singing') {
    continue;
  }
  console.log(love);
}

Because I love all of these things but one of them is the odd one out! The expected output would be:

Software Engineering
Coding
JavaScript
Codecademy

When not to use a for...of loop

Well, for a start...

When ITERATING THROUGH AN ARRAY in REVERSE.

for...of Loop Practice Challenges

Arrrrrrgh I can get the to WORK... but I don't UNDERSTAND how they work!!!

WAIT SO THERE ARE for...in loops as well? 

I am struggling here. There's a lot to take in at once.

I can barely even understand for...of loops. I spent so long revising all of those expressions... and now they want to just take them away. 

But only at the right times!!! It's so confusing.

What on earth even is a for...in loop as well?

What I have to say to myself is this: is this really all urgent right now? 

Can I come back to this in a few days time?

Is it all urgent?

Written This Morning: Plan for the Day

(This is something I wrote at the start of the day. I will come back to it later for now. 🤗)

I am feeling a bit lost and disorientated and overwhelmed today so I would like to map out my plans. As I have a pretty empty day i.e. one that I need to structure all by myself for self study.

So the plan for me is this

Morning

  • Read over Codecademy's informational on for loops and over loops stuff. Write up all and any notes I have.
  • Revise over
    • While loops
    • Do...while statements
    • Breaks
  • Revise over my whale song project that I built yesterday
    • Because I built it very quickly

Maybe share with team.

Afternoon

Start on objects - I also have a 1:1 with a mentor so depending on how loops go I may just talk to them about those - 

Or hopefully, and alternatively, perhaps, I can 

  • Finish the above
  • Start on objects before
  • And maybe I can come into my 1:1 already with some questions on objects. 😊

Later: I was way too ambitious omg - or maybe, I just really needed to revise loops (and for...of loops). 

Comments

Popular posts from this blog

Hello World

Yosemite

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