Week 2 – Blog Post

Blog Questions:

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 false. This can be done in the developer console. Coercion is the process of converting the type of one value to another.

// test the falsey-ness of a number or string

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

To convert a for loop to a while loop you use the same principals but you have to restructure the arguments.

for ( ForInit ; Expression ; ForUpdate ) Statement
// this is basic for syntax
// now to convert to a while statement we reorder
while (Expression) {
// both of these loops work the same way

As for the week work, heres the directory drop. I have to work on organizing files, I know.

Join the Conversation

1 Comment

  1. Had a look at your ‘climbing the mountain’ solution and would be cool if you considered a way to build the ‘spaces’ based on the phrase length. Also you should note that String.substr() is a legacy function and has been replaced by String.substring().

    And have a look at akane2’s clever solution to the ‘climbing the mountain’ problem. It involves using String.repeat() allowing to build a solution that phrase length dependent and use just a single loop.

Leave a comment

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