[WEEK #2] – 09 JavaScript Basics – Control Flow + Problem Sets + Blog Question

Hey guys. This week was pretty fun. I am actually enjoying this programming language more than others that I have learned. This week was not that challenging but one of the questions in the problem set made me use GooGle. I had to look up some new tools and resources for help.


Problem Sets

Blog Question

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 test if a value is true or not in the developer console. Type coercion is to coerce a number to a string and a string to a number. In other words its one primitive type to another.

!Number(str) //to test if that's a number

Falsy Values

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

First, a for loop has a initializer, condition, and increment-er. A while loop only has a condition. You have initialize the while loop out side of the loop and increment it inside of the while loop. You can declare it before setting the condition.

while (someCondition){
    runs some code

for (init; condition; step){
    runs code

Join the Conversation

1 Comment

Leave a comment

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