array to string ruby

array = [1, 2, 3, 4, 5]
string = array.join(', ')
puts string

Explanation: - array is initialized with values [1, 2, 3, 4, 5]. - join method is used on the array with ', ' as an argument, creating a string where each element of the array is separated by ', '. - The resulting string is stored in the variable string. - puts outputs the string to the console.