Question It All
Question It All
A beautiful song by Lucy Rose...
Okay, so I'm sorry. After spotlighting this song yesterday at the end of the post, I quite simply have to name my blog post after this. I'm OBSESSED with this song.
It's so beautiful - it's like nothing else that I have ever heard before.
It reminds me of the hills and the forests near my house in Luxembourg, like I said last night, and how I walked on them, dreaming, dreaming - dreaming, and knowing that I was following my destiny.
Of my commitment to be a software engineer. Of the path that slowly, slowly emerged to me, somehow, as I was walking through those hills.
Of my commitment to be a software engineer. Of the path that slowly, slowly emerged to me, somehow, as I was walking through those hills.
Out of everything, everything in the world that I could be - I chose this.
Except that I didn't choose this. It chose me. And I'm so happy and grateful forever that it did. Thank you.
Album Artwork for Question It All by Lucy Rose. |
Revising Nested Loops
I made some mistakes with Nested Loops last night but it turns out they weren't so bad. Here is the correct(ed) code that I managed to get from my boss and here are the one or two mistakes I made with it:
const samsHobbies = ["cycling", "skiing", "dancing", "singing", "bungee jumping", "mountain climbing", "parachuting", "crochet", "ice-cream making"];
const sallysHobbies = ["dancing", "swimming", "singing", "ice-cream making", "stargazing", "knitting", "parachuting", "painting", "graffiti", "crochet"];
const mutualHobbies = [];
for (let i = 0; i < samsHobbies.length; i++) {
for (let j = 0; j < sallysHobbies.length; j++) {
if (samsHobbies[i] === sallysHobbies[j]) {
mutualHobbies.push(samsHobbies[i])
}
}
}
console.log(mutualHobbies);
The line I really struggled with is the penultimate line of code -
mutualHobbies.push(samsHobbies[i]);
We are pushing TO mutualHobbies. But we are pushing FROM samsHobbies - whatever number it is that we are on now - IF and only IF the conditions are satisfied!!!
The While Loop
(again. Thank you)
From the Codecademy course, on when we should use a while loop versus when we should use a for loop.
"The syntax of a while loops is ideal when we don't know in advance how many times the loop should run. Think of eating like a while loop: when you start taking bites, you don't know the exact number you'll need to become full. Rather you'll eat while you're hungry. In situations when we want a loop to execute an undetermined number of time, while loops are the best choice".
So let's go over that syntax once again, one more time for me, please. Thank you.
So the syntax is:
let i = 1;
while ( i < 5) {
i++;
}
console.log(i);
//Expected output: 5
Right. Let's go on and maybe actually do some while loops, then, shall we?
Well that was fun.
Do While Loops
I started looking at these. Basically, they execute the loop once NO MATTER WHAT.
But then they always check based on the conditions being met for any further iterations.
More on this tomorrow! <3
Comments
Post a Comment