strings.each do |lett|
if lett == “S”
symbols.push(lett.to_sym)
end
end
print symbols
I understand from the exercise explanation that if one of the strings stored in the VARIABLE STRINGS has the S letter then store that string in the VARIABLE SYMBOLS, so this let symbols with CSS and JAVASCRIPT stored with him.
I checked the forum before post this but none of the answers clarifies me.
#strings="So so So iS a String"
strings="SsSiSaS"
#pre define an empty Array
symbols=[]
symbols1=[]
#split(" ") will use a =space-character= as Element-separator (you get words)
#split("") will lead to =every-character= being seen as an Element
strings.split("").each do |lett|
print lett
if lett == "S"
symbols.push(lett.to_sym)
symbols1<<lett.to_sym
end
end
print "\n==a new-line==\n"
print symbols
print "==a new-line==\n"
print symbols1