Skip to content

Commit 668e730

Browse files
committed
initial commit
1 parent 61bc1d4 commit 668e730

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

reverse_string.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
def word_split(sentence)
3+
sentence.split(" ")
4+
end
5+
6+
puts "enter a sentence with five or more letter words: "
7+
sentence = gets.chomp
8+
words = word_split(sentence)
9+
reverse_words = []
10+
11+
words.each do |word|
12+
reverse_words.push(word.length >= 5 ? word.reverse : word)
13+
end
14+
15+
puts reverse_words.join(" ")

0 commit comments

Comments
 (0)