Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

done #23

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

done #23

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions data-collections.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,89 +9,89 @@ planeteers = ["Earth", "Wind", "Captain Planet", "Fire", "Water"]
Access the second value in `planeteers`.

```rb
# Your answer here
# planeteers[0]
```

Add "Heart" to the end of `planeteers`.

```rb
# Your answer here
# planeteers << "Heart"
```

Remove "Captain Planet" from the array (without using a method).

```rb
# Your answer here
# planeteers -= ["Captain Planet"]
```

Combine `planeteers` with `rangers = ["Red", "Blue", "Pink", "Yellow", "Black"]` and save the result in a variable called `heroes`.

```rb
# Your answer here
# heroes = planeteers + rangers
```

Alphabetize the contents of `heroes` using a method. [The Ruby documentation might help](http://ruby-doc.org/core-2.2.0/Array.html).

```rb
# Your answer here
# heroes.sort
```

Randomize the contents of `heroes` using a method. [The Ruby documentation might help](http://ruby-doc.org/core-2.2.0/Array.html).

```rb
# Your answer here
# heroes.shuffle
```

#### Bonus

Select a random element from `heroes` using a method. [The Ruby documentation might help](http://ruby-doc.org/core-2.2.0/Array.html).

```rb
# Your answer here
# heroes.sample
```

Select all elements in `heroes` that begin with "B" using a method. [The Ruby documentation might help](http://ruby-doc.org/core-2.2.0/Array.html).

```rb
# Your answer here
#
```

### Hashes

Initialize a hash called `ninja_turtle` with the properties `name`, `weapon` and `radical`. They should have values of "Michelangelo", "Nunchuks" and `true` respectively.

```rb
# Your answer here
# ninja_turtle = {:name => "Michelangelo", :weapon => "Nunchuks", :radical => true}
```

Add a key `age` to `ninja_turtle`. Set it to whatever numerical value you'd like.

```rb
# Your answer here
# ninja_turtle = ninja_turtle.merge(:age=>3)
```

Remove the `radical` key-value pair from `ninja_turtle`.

```rb
# Your answer here
# ninja_turtle.delete(:radical)
```

Add a key `pizza_toppings` to `ninja_turtle`. Set it to an array of strings (e.g., `["cheese", "pepperoni", "peppers"]`).

```rb
# Your answer here
# ninja_turtle = ninja_turtle.merge(:pizza_toppings => ["cheese", "pepperoni","peppers"])
```

Access the first element of `pizza_toppings`.

```rb
# Your answer here
# ninja_turtle[:pizza_toppings][0]
```

Produce an array containing all of `ninja_turtle`'s keys using a method. [The Ruby documentation might help](http://ruby-doc.org/core-1.9.3/Hash.html).

```rb
# Your answer here
# ninja_turtle.keys
```

#### Bonus
Expand Down
24 changes: 11 additions & 13 deletions data-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,44 +10,43 @@
2 ** 3
```
```text
Your answer.
8
```

```rb
((16 / 4) * (2 + 1)) ** 2
```
```text
Your answer.
144
```

```rb
("a milli " + "a milli") * 3
```
```text
Your answer.
a milli a millia milli a millia milli a milli
```

```rb
("a milli " * 4) / 2
```
```text
Your answer.
Error out
```

```rb
my_favorite_number = 13
puts "My favorite number is: " + my_favorite_number
```
```text
Your answer.
```
Error out
```

```rb
my_favorite_number = 13
puts "My favorite number is: #{my_favorite_number}"
```
```text
Your answer.
My favorite number is: 13
```

### Truthiness and Falsiness
Expand Down Expand Up @@ -78,7 +77,7 @@ if no_name
end
```
```text
Your answer.
My name is:
```

```rb
Expand All @@ -88,7 +87,7 @@ if no_name
end
```
```text
Your answer.
nil
```

```rb
Expand All @@ -98,8 +97,7 @@ if age
end
```
```text
Your answer.
```
error ```

```rb
age = gets.chomp
Expand All @@ -108,7 +106,7 @@ if age
end
```
```text
Your answer.
nothing
```

### Conditionals
Expand Down