Question on pushing a string to an array


#1



How do you break a string into words and push it into an array?

For example the string "I love to code"
How would I make it look like this?

Array = ["I", "love" , "to", "code"]


Replace this line with your code. 
string = "I love to code"

array = []
array.push(string)


#2

https://ruby-doc.org/core-2.2.0/String.html#method-i-split


#3

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