Liked this course, fun playing with loops, arrays and learning about objects. Had a few issues though.
First problem was that sometimes I type too fast or I’m not being careful enough. When I was meant to type ‘ += ‘ I would type ‘ =+ ‘, for when I wanted to add something to a variable. This caused me a few “OMG! Why isn’t it working?!” moments. Luckily though I figure out what I was doing wrong just before posting a question to the Treehouse forum.
Another thing I discovered was about errors showing up! The images below show the code with the error, the error message that came up in the console and the corrected code.
So, this problem has a 2-dimensional array and what I did was missed a comma in the outer array. This made the program throw an error BUT the error message was not coming up saying it was on line 6.
How did I realise I had made this mistake? Again, was about to ask a question in Treehouse and when you do start to ask a question it pops up questions that have already been asked that are similar to yours. Had a look at these and one mention that often errors occur by missing out a comma or semi-colon. So I had a closer, more careful look through my code, not just at the lines that the console and told me their were errors out.
Good to learn that the cause of an error may not be where you think it is! Something to try and remember and to get better at typing without missing out commas etc!! Also, to think about is that even though it the console did not give the line the error was on, with it saying line 17, I could have thought about what variables/objects/functions were in that line and then looked at them. This would be a good way to tackle errors in a large program!
The last thing that I got thinking about while doing this course was when to use/write a function? In the last challenge, in my solution I got it working with a for loop inside a while loop. The solution that Dave from Treehouse showed used a function for the for loop part. I want to know how do you decide when you should create/write/use a function?