Set Yourself on Fire, Part II

Set Yourself On Fire, Part II

"Now come and stand, see the sights and warm your hands, and fan the flame inside of me." - Charlotte Gainsbourg, 'Set Yourself On Fire'

I bought  a book over the weekend and it changed my life. 

I woke up on Saturday, knowing that I needed to go to London, and that I needed to go to Foyles, and that I needed to buy myself a JavaScript book there. So that's exactly what I did. 

I read about Rock Paper Scissors in it. 

And lo and behold, on Sunday, I woke up, and I knew the answer to my Rock Paper Scissors question I had been not only stuck on but distraught over for the past few days. 

What was I doing wrong? I had been trying to put an if/else statement inside of a function. I had spent so long on functions that I had forgotten that you do not actually need to put if/else statements inside of them...



Further Thoughts On RPS

Again, I have been learning with Carlos. Carlos is so, so good. Carlos is so, so, so, so, so, so, so good. I always learn so much from listening to him and listening to him speaking aloud. (Carlos is a Web Developer from Brooklyn who does the Codecademy videos for JavaScript projects).

What I have learned from him today is:

'NESTED IF STATEMENTS'

Nested if statements. 

Nested if statements.

Nested if statements.

Nested if statements.

Nested if statements.

Nested if statements.

Nested if statements.

Nested if statements.

I was trying so, so hard, to put a name, and a label to something, and I couldn't figure out what this was called. But then when I heard Carlos say it aloud, then I knew what the name was: Nested if statements.

if (userChoice = 'rock') {

    if (computerChoice = 'paper'){

        return 'The Computer is the WINNER!!!'

    } else {

        return 'You have WON! YAYYY!!!'

    }

}

Such is a nested if statement.

In the immortal words of Carlos, a nested if statement is just

  • 'an if statement inside of another if statement', and
  • 'we are allowed to list as many if statements inside of each other as we want'.

Rosana has previously told me to make myself JS cheat sheets and I do plan to do this, once I have a lull in my JS learning again (right now, I'm on a ROLLL). 

The Triple Equals Signs ===

I was making a mistake - I was forgetting to put triple === signs in my statements. Important to remember a single = is only used when assigning a name to a function or a variable - at least, in my learning so far - and not when checking if values are actually equal to one another

Comments

Popular posts from this blog

Hello World

Yosemite

Where To Hide A Star