JSFiddle - React, Tailwind, and code Playground

JavaScript

const buildObject = (textArray, memory) => {
  return Object.assign(
    {},
    {
      replies: textArray.map(x => {
        return {
           type: 'text',
           value: x
          }
        })
    },
    memory ? {conversation: memory} : null
  )
}
var memory = { };

//with memory
console.log(buildObject(['one', 'two', 'three'], memory ))

//without memeory
console.log(buildObject(['one', 'two', 'three']));