Complete the "Build Front-End Web A... Star this Commitment
Week 3 of 10

joshmrallen commits to:
Doing 2 hours per day, one in the morning, one in the evening, Mon thru Fri, and 6 hours over the weekend for a total of 16 hours per week (4 hours Sat, 2 hours Sun or whichever is convenient) with proof of time logged via screenshots.
Maintain sleep/wake habits in order to wake up and accomplish daily goal: meditate before bed, wake up at 5am, get to sleep by 10pm.
Last reported: Success
Next report due:
July 24
4:00 AM GMT
Commitment Journal
July 21, 2018, 4:11 PM
Up and about. I’ll do 2 hours this morning and 4 hours tomorrow, Sunday.

Continuing to check on what might be going wrong. In the code academy terminal, I opened their text file to see, just in case, how their getneighborhoodBombs method looked like. As far as I can tell, they don’t use any arrow function syntax.

I wonder, if I changed to the regular syntax, if that’ll fix the error?

Because everything is pretty much the same — well except for the fact they have a few more methods in there and use an older way of defining classes.

Something’s showing undefined. Checking generate board. Doing this by using the getter.

Terminal shows all blank spaces in playerBoard which is good because we haven’t used the playMove method for anything to change. So far so good.

Now, checking getNeighborhoodBombs again and flipTile to see if there’s anything that’s messing anything up.

Ok, getNeighborhoodBombs is working and the number is being added as a string when flipTile is called. Printing out the playerBoard shows that all rows and columns are as they should be after just playing 1 turn.

The only time the error shows is when the print method is called and join is encountered. Sometime before join must need to be read — perhaps something that’s supposed to be there. Perhaps change back to regular function syntax?

The error still happens right at join. The syntax is not the issue. Googling to see if anyone else has ever gotten this issue.

So for join to be returning errors, it’s not reading the array before it as an array. Perhaps something’s wrong with the .map output.

Ah hah! each row of the board is being output as objects and not arrays. That’s why join isn’t working. How can I fix this? Use a method to change each row to an array before calling each row with map and join. Do this in the print function before the console.log.

Which method though? Searching. Here’s what Doug Neiner says on stack overflow when I searched:
Just use the jQuery utility function makeArray
arguments is not an Array, it is an object. But, since it so "array-like", you can call the jQuery utility function makeArray to make it work:
var displayIt = function() {
return 'the list: ' + $.makeArray(arguments).join(",");
$("#main").append('<p>' + displayIt('111', '222', '333') + '</p>');
Though he posted this back in 2010, so I’m not sure if anything has changed since then. I’ll search the documentation for makeArray.

Coming up on the 2nd hour and I’ve found that makeArray is something apart of jQuery. I’m not too sure what jQuery is. Checking.

Do I need to do anything special in order to use jQuery? Ohhh, jQuery is a JavaScript library that you can download and install.

To be sure, I just used Array.isArray() to check whether or not it really is an array or not and it returned true. typeof still return ‘object’ though. Oh, I think arrays are a type of object to begin with. That explains a few things I guess.

So, back to square one with this -_-

Back to asking the team for help. Thank goodness for this inapp chat.

Uh, still waiting for a response. Another 10 minutes.

Finally got back to me. I’m talking to Marvin now. I might actually go for the 4 hours today haha. This is taking a while.

Anyways, this guy tells me it’s my arrow function syntax (it’s not). Maybe it’s my text editor. I don’t know. I’m done for now. 4 Hours tomorrow.
July 21, 2018, 4:25 AM
So, I went to sleep super late again last night. Went to a Hackerspace and learned that it’s totally free to take my own stuff over there to work on because they’re a public space. You only pay to become a member if you need to use equipment, etc. So maybe later on, if I’m in the city on the weekend waiting for Daisy to finish something, I can go over and work on stuff over there. And everyone’s got experience building, coding, etc. Exciting!

Beginning both hours right now, since I slept in this morning and wasn’t able to fit in the 1st hour.

Continuing on with step 32: continuing to check my work since I apparently built out the logic first. So, let’s see.

Looks like I missed a ! for hasSafeTiles, since we’re checking to see if there are no safe tiles. So we’re checking if it’s false.

Seems my printboard method should just print the player board. The player shouldn’t be able to see the bomb board! Changing now.

And that should do it for flipTile. Seems I made a few mistakes last night. too sleepy.

now to test the classes and methods.

before I do that, I’ll see if any errors come up.

hmm, && is unrecognized. maybe the ! should go on the outside of the parentheses.

Woo, no errors anymore! Now to call classes and methods.

It seems even in the original class where a static is defined, you need to use classname.staticmethod to use it.

it’s telling me that my generateNumberOfNeighborBombs is not a function…maybe put flipTile after generateNumberOfNeighborBombs?

ohh i see another problem. that whole method is calling properties when before when it was its own function they were unique to the function.

Looks like there was one part where I wrote this._bomb.getNumberOfNeighborBombs haha. Just changed it to this._board.getNumberOfNeighborBombs. see if that solves the issue?

now it says join is not a function — this is coming from the print function. So I can see where my code is going as I fix each bug. I love this.

I’m realizing gradually that you don’t need a printBombBoard method because eventually the Bombs are shown on the player board as it sets the bomb locations equal to those locations on the playerBoard.

Hmm, have to look up the .map method to get an idea of how to fix this. Not sure what to do, so I’ll look at a hint or ask. Oh, no hint for this. I submitted a question and pasted the error I’m seeing.

Stephanie helped me find my error!

"...Because your board should be an array of arrays
On the first foreach, you're iterating through each of the inner arrays and joining them into a string
So before you join anything, you need to confirm that playerBoard is indeed an array of arrays.
Yeah, so you can see the first value of playerBoard is a number, not an array
Which is where your error is coming from."

General advice:
If you ever get stuck, just walk through each step as if you're the computer. Determine what each variable should be equal to, and print them out to make sure that they are equal to what they should be. If not, then at that point you kinda have an idea of where to start debugging.

So, my issue is that once a tile is added the number for neighboring bombs, the print board method doesn’t work, because the join method must take a string, not a number.

So in that foreach in getnumberofneighboringbombs, I need to figure out how to make the number a string. Checking the documentation for how to do that.

So on line 146, I have taken the const row = []; from the outer for loop. But when I tried printBoard(), it still showed an error.

Definitely should be inside the outer for loop I think. Putting it back.

Can’t figure out why it’s not printing the rest of that row and only 2. I’ll come back to it in the morning.
July 20, 2018, 11:30 AM
To be clear, I’ll definitely be doing both hours tonight.
July 20, 2018, 9:52 AM
Meditation from last night. Getting to bed too late. Needed some more sleep this morning.
  • Jul 3, 2018
  • Jul 3, 2018
  • Jul 3, 2018
  • Jul 3, 2018
  • Jul 3, 2018
  • Jul 3, 2018
  • Jul 3, 2018
  • Jul 3, 2018
  • Jul 3, 2018
  • Jul 3, 2018
  • Jul 3, 2018
  • Jul 3, 2018
Displaying 1-2 of 2 results.
July 10 to July 17

- Referee approval report
- Committed user success report
July 3 to July 10

- Referee approval report
- Committed user success report
Recipient of Stakes
Money to a friend ($5.00 to AzuLes5 per failed reporting period)
To change the Recipient of Stakes for your Complete the "Build Front-End Web A... Commitment, enter their email address or stickK username below.
Total at stake: $50.00
Stakes per period: $5.00
Remaining Stakes: $40.00
Total Money Lost: $0.00
This Commitment doesn't have any Supporters yet!