- See more at: http://blogtimenow.com/blogging/automatically-redirect-blogger-blog-another-blog-website/#sthash.YsVbCxL0.dpuf Journey to Becoming a Web Developer: Iteration in JavaScript vs. Ruby

Saturday, November 16, 2013

Iteration in JavaScript vs. Ruby

During class we used this javascript iteration example:








to demonstrate how iteration works. We were then asked to do the same iteration example in Ruby.

This is mine:








In my opinion the JavaScript example was a lot clearer. After seeing it I understood better how iteration works because each step was shown. In the Ruby example all of the steps are inside of the .times method, so it's harder to understand the concept when all of the steps are hidden. I like that the words state, condition, and increment were used to explain iteration in JavaScript. In the example i = 0 is the current state of i, i < 101 is the condition that has to be met, and i++ is the increment meaning what we want to increment i by in this case we want to increment i by 1. When facing an iteration problem that I don't understand I can refer to those words to get me on track. I was studying Ruby for a little bit before this program and thought I fully understood iteration, but after this lecture realized I didn't know it that well at all. So this was very helpful for me.   JavaScript is clearer to me when it comes to iteration, but to learn Ruby and JavaScript simultaneously maybe a bit difficult for me at this point because I'm still trying to understand the concepts of programming, but if there are concepts other than iteration in JavaScript that can help me understand Ruby better then I'm all for it.

No comments:

Post a Comment