Thursday, November 10, 2016
Switch and loops
Today I read about switches and loops. The format for the switch is switch(expression) {case n: code block break;case n: code block break;default:default code block}. It seemed easy on the test run and on the definitions, however it was not. I tried to use the switch in my game of choice and it did not work. I could not figure out what was wrong with my code. I even had it in the right format! This was by far the most difficult code that I have come across by far. The for loop was easy to understand as well but had a more complex format. There were too many formats to copy here solely because there were many variants of the loop. I have used it in the exercises and in code academy and it was fairly easy to use. Some problems that I came across were the infinite looping caused by syntax errors. This code is something that I can see myself using but would have to check the format every time I used it. I personally dislike the switch because of my past experience, but I look forward to using the loop more.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment