Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'sinatra'
- def stringify_array(arr)
- return "not an array" unless arr.is_a? Array
- return arr.join("$").split("$")
- end
- get '/' do
- "<pre>
- Using a combination of Array’s join method and String’s split method, write a line of code that converts [1,2,3] into [\"1\", \"2\", \"3\"].
- ANSWER
- def stringify_array(array)
- return \"not an array\" unless arr.is_a? Array
- return arr.join('$').split('$')
- end
- stringify_array([1,2,3,4,5,6,7,8]) = #{stringify_array([1,2,3,4,5,6,7,8])}
- </pre>"
- end
Advertisement
Add Comment
Please, Sign In to add comment