9. Is This the right output?


#1
strings = ["HTML", "CSS", "JavaScript", "Python", "Ruby"]

# Add your code below!
symbols = []

strings.each do |s|
    for s in strings
        symbols.push(s.to_sym)
end
end`

That is the code I used that worked, but this was my output.

["HTML", "CSS", "JavaScript", "Python", "Ruby"]

If I am thinking correctly. Shouldn't the output be only CSS and JavaScript?


#2

Hi

nope because the string.each do {} go throught all the element iniside the array strings and then inside the for in it push each element inside the array symbols and change it into string.
Hope that could help you understand.


#3

So if I understand correctly. S was just used as a sort of temporary variable?


#4

yes the string.each do {} store each element inside the array strings into the letter s if you do...

strings = ["HTML", "CSS", "JavaScript", "Python", "Ruby"]

# Add your code below!
symbols = []

strings.each do |s|
    puts s
end

#ouput
HTML
CSS
JavaScript
Python
Ruby

#5

Awesome! Thanks for the explanation!


#6

2 posts were split to a new topic: What to Put in Symbols Box?


#16

This topic is solved.