Day 5.4 Exercise 32 Loops and Arrays

Here’s my work.
Here’s the link to exercise 32.

Ex32 Code
Ex32 Code
Ex32a Code
Ex32a Study Drill 3
Ex32 Output Combined
Ex32 Combined exercise output

 

Study Drill

1. Take a look at how you used (0..5) in the last for -loop. Look up Ruby’s “range operator” (.. and …) online to see what it does.
(..) includes the last number included, (…) does not include the last number.

2. Change the first for number in the_count to be a more typical .each style loop like the others.
Done.

3. Find the Ruby documentation on arrays  and read about them. What other operations can you do besides the push function? Try <<, which is the same as push but is an operator. fruits << x is the same as fruits.push(x).
Done, it’s on the 2nd picture. Both ways works the same, however I wish I only knew one, so it doesn’t confuse me.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s