A string in Ruby is an data type that holds words, numbers, and other characters. A string is just data. This lab is a refresher on how to create and manipulate strings. You'll code your solution in silly_string.rb
You can read about strings and all the methods available here.
Write your code and test it out manually by running ruby silly_string.rb
in the command line. If the output looks like it's intended to, you're good to go!
-
Create a string that contains your favorite word, and save it to a variable called
my_word
. -
Using a method built into ruby, capitalize every letter in the string you just created
-
Now let's make all the characters lowercase in the string
"IM NOT SHOUTING"
-
Using a method built into ruby, count how many letters are in the string
"Karlie Kloss"
-
Now let's add more words to that string, using
+
just like in math - That's called concatenation. Let's add together to the two strings"wow"
and"mom"
. -
Now let's capitalize just the first letter of the sentence
"i really like programming"
-
Let's take the string
"Astounding aardvarks, arguably an ancient animal, always ate apples and acorns and artichokes all around Athens, amazing!"
. We want to use thegsub
method to switch allA
s forO
s, as well as alla
s foro
s. We'll need to chaingsub
s. -
Save each of the following strings to its own variable, then concatenate the variables in the order of the Kode with Klossy Camps!
- "Chicago"
- "Los Angeles"
- "New York"
- "Saint Louis"
- "Detroit"
- "Oakland"
- "Austin"