Write an .each loop that goes through words and just prints out each word it finds


#1




getting error

Oops, try again. It looks like you didn't print each word from the user's text to the console.

Not understanding what I should be putting instead?

puts "He declares"
text=gets.chomp
words.split ("He, declares")

puts "She declares"
redact=gets.chomp
words.split ("She, declares")

words.each {|s| print}


#2

Maybe you´re an advanced student, I don´t get what you pretend to do with that | s |. What´s that supposed to print?

If it helps, I´m leaving my code here. In the .each loop, I order to print whatever is inside of the array "words".

puts "Write some text!"
text = gets.chomp
puts "Text to redact"
redact = gets.chomp

words = text.split(" ")

words.each do |word|
    print word
end

#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.