session1/challenge/6_string.rb
def odds_and_evens(string, return_odds)
  output = []
  if return_odds
    string.chars.each_with_index{|x, i|
      output << x if i.odd?}
  else
    string.chars.each_with_index{|x, i|
    output << x if i.even?}
 end
 return output.join
end
# You'll get a string and a boolean.
# When the boolean is true, return a new string containing all the odd characters.
# When the boolean is false, return a new string containing all the even characters.
#
# If you have no idea where to begin, remember to check out the cheatsheets for string and logic/control
#
# odds_and_evens("abcdefg",true)    # => "bdf"
# odds_and_evens("abcdefg",false)   # => "aceg"
You'll get a string and a boolean.
When the boolean is true, return a new string containing all the odd characters.
When the boolean is false, return a new string containing all the even characters.

If you have no idea where to begin, remember to check out the cheatsheets for string and logic/control


You ' ll get a string and a boolean . When the boolean is true return a new string containing all the odd characters . When the boolean is false return a new string containing all the even characters . If you have no idea where to begin remember to check out the cheatsheets for string and logic / control
def odds_and_evens(string, return_odds)
  output = []
  if return_odds
    string.chars.each_with_index{|x, i|
      output << x if i.odd?}
  else
    string.chars.each_with_index{|x, i|
    output << x if i.even?}
 end
 return output.join
end
def odds_and_evens ( string , return_odds ) output = [ ] if return_odds string . chars . each_with_index { | x , i | output << x if i . odd? } else string . chars . each_with_index { | x , i | output << x if i . even? } end return output . join end
You'll get a string and a boolean.
You ' ll get a string and a boolean .
string
return_odds