Ex 24 B...I'm lost!


#1

I don’t have a strong background in js or python or any programming language, and I’ve been loving the course because i’ve been able to follow and complete challenges.

When I get to Ex 24 B, I feel lost. I can’t quite understand how the code works in Ex 24A. It’d be very helpful if you explained the OO example building it line by line on Ex 24A as you did in Ex 20.


#2

Hey @iamtirado, so I’m a little confused, what do you mean by “24A” vs. “24B”? Do you mean the videos? Or, do you mean the code and then the WYSS output at the end?

Now, as for understanding the code, here’s some steps to take to make it easier:

  1. You are probably looking at this and it’s just too much. But, remember I say to do things in small chunks, SO! Rip out every room except Well. Strip it down to the bare minimum necessary to understand, and then study that. 1 room. 1 Game. Figure that out.
  2. If you still can’t get it then strip out the contents of Well.enter() so that it just does a console.log("Well.enter") and then analyze the code.
  3. YOU MUST UNDERSTAND THE . I find this is the one thing that keeps people from getting OOP code. If you don’t know what the . (dot) in game.play() does then come back here and attempt to explain it to me so I can see if I can reword it. Realize I am NOT asking what does play() do, I’m asking only what does the dot do.
  4. Use console.log to trace what is going on and follow each function called on each object. If you can’t trace it that way then read https://nodejs.org/api/debugger.html and use the debugger to stop where you are confused, and then step through and take notes on where the code goes.

Try those things then come back with some explanations of what you think is going on. One thing is you’re kind of saying “figure this all out for me”, but it’s a lot better if you come back and say “I am confused as to what this line, this line, and this line, does or how X does this.” Then show some code and then it’s easier to correct what you think is going on.