Is it really just week two?

I feel like I’ve been doing javascript forever because I’ve been learning so much. Am I understanding everything? Ha! No, I am not fully understanding but I tend to go back to the code along for assistance.

How can you use “falsey-ness” to determine if a string value can be coerced to a number? Why does this work? What is “type coercion” anyway?

  • You can use “falsey-ness” to determine if a string value can be coerced to a number by (I’ll keep you updated on this answer).
  • Type coercion is when you change a type of value to a different type of value. For example changing a Number( ) to a “string” or vice versa.

What do you need to do to convert a for loop to a while loop?

  • In order to change a for loop to a while loop, you wouldn’t need to know the number of repetitions like how you NEED to know it for, (for loops). For example, while (condition) { //run some code } vs. for (int; condition; step {//run some code}
  • This is an example of a for loops below:
for(let i = 300; i <= 333; i++) {
    if(i % 2 !==0){
        console.log(i);
    }
}

This is an example of a while loop below:

let num = 1;
while(num<= 20) {
    if(num % 4 === 0){
        console.log(num);
    }
    num++;
}

This week contained a lot of information that I can’t memorize just from looking at it once, I have to keep looking at my notes to know where to put what. I guess switch statements were not so bad but trying to understand for loops and while loops have me feeling like a granny. Here are the exercises:

bouncer.html / bouncer.js

number-guess / number-guess.js

while-loops / while-loops.js

annoy -o- matic.html / annoy -o- matic.js

for-loops.html / for-loops.js

These are the problem sets:

feeling.html / feeling.js

running.html / running.js

weather.html / weather.js

guess.html / guess.js

stairs.html / stairs.js

mountain.html / mountain.js

Join the Conversation

1 Comment

  1. Wow this is one clever solution to the ‘Climbing the Mountain’ problem. I bet you have some amazing Google-foo that led to the String.repeat() method. Very neat!

    //little simpler starting with i at the last index of 'phrase'
    let phrase = "Climbing up the Mountain" 
    for (let i = phrase.length - 1; i >= 0; i--){
       stair = ' '.repeat(i) + phrase[i];
       console.log(stair);   
    }
    

    The one bit I actually found most curious is how you don’t need to declare the space variable with a let or var keyword. What a surprise!

Leave a comment

Your email address will not be published. Required fields are marked *

css.php