Friday, April 24, 2015

Friday, April 24th

Today was a regular class. We were supposed to have class Thursday, but because of Independence Day we didn't have school Thursday, so our class was pushed to Friday. Nothing special about class besides that though.

I kept working on String 2, and I realised that I will most likely finish String 2 before the quarter ends. This is because there aren't as many string problems as array problems. Of course, I could be wrong in saying that, because they might turn out to be very hard. But if I keep working at the pace that I am now, I should finish all the problems before the year ends.

I am still getting used to strings again. I was working on a problem for the whole class, and it was only at the end of class when I told Mr. Daly that I was very confused about all of these problems, that he explained to me a very important concept in Strings. Less of a concept, more of a method in coding. The indexOf method. indexOf tells you when a word starts in the string. For example, if my string is "hellomynameis" and I code str.indexOf("my");     the computer will tell me at what part of the string the word my comes in. So in that case, I would get the number 4.

This method will come in handy a lot in my String 2 problems, because they often ask me to do things that require taking a part of a string and doing something with it. Up until now, I was confused how to. But from now on, I'm sure that this method will help me.

However, I won't be showing an indexOf problem today. I will be showing one for next class's blog.
Here is today's problem:
----------------------------------------------------------------------------------------------------------------------------------
Return true if the given string contains a "bob" string, but where the middle 'o' char can be any char.

bobThere("abcbob") → true
bobThere("b9b") → true
bobThere("bac") → false















No comments:

Post a Comment