Run your Ruby file by typing ruby
and then the name of the file you want to run in the Terminal.
If we want to run each_even_word.rb
, we can write the command:
ruby each_even_word.rb
To re-run this command, you can use the UP and DOWN arrow keys to look at the history of commands you've run in a Terminal.
Write a program that:
Asks your user to enter any word and have it spelled out letter by letter.
Input
Georgia
Output
"G"
"E"
"O"
"R"
"G"
"I"
"A"
Example
"Enter a word for me to spell:"
Georgia
"G"
"E"
"O"
"R"
"G"
"I"
"A"
Write a program that: Asks the user to enter a list of words separated by spaces. The program should only print the words that are have an even number of characters
Example (mountain pink vines
is the input)
"Enter a list of words separated by spaces:"
mountain pink vines
"mountain"
"pink"
Write a program that:
Asks the user to enter a word. The program should print each letter in the word the number of times it appears in the word.
Example input: loop
Output:
"Enter a word"
loop
l appears 1 times
o appears 2 times
o appears 2 times
p appears 1 times
Click here to see names of each test
each_spell_word.rb spells 'Georgia' correctly
each_spell_word.rb spells 'Supercalifragilisticexpialidocious' correctly
each_letter_count.rb prints the letters and number of times the letters appear for the word 'levee'
each_letter_count.rb prints the letters and number of times the letters appear for the word 'loop'
each_even_word.rb prints the 'mountain' and 'pink' when the input is 'mountain pink vines'
each_even_word.rb prints nothing when the input is 'odd numbers squad'