Week #2: Tutorials + JS Control Flow Problem Set.

Tutorials:

Here is a link to this week’s tutorial exercises.

Problem Set:

feelings.html/feelings.js

running.html/running.js

weather.html/weather.js

fizzbuzz.html/fizzbuzz.js

guessing-game.html/guessing-game.js

stairs.html/stairs.js

Blog Questions

Use the code insert tool and provide examples to answer these two questions. Use JS comment syntax to describe your example.

  • 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?

Falsey-ness can be used to test if a value is true or not in the developer console. Type coercion is for coercing a number to a string and a string to a number.

!Number(str) //to test if it's a number
Falsy Values
false
""
null
undefined
NaN

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

You have to initialize the while loop outside of the for loop and increment it inside of the while loop. You can declare that before setting the condition.

Join the Conversation

1 Comment

Leave a comment

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

css.php