-1

I'm looking to add a line break to the following array. Using \n doesn't seem to work.

const output = {
  message: [
      `Hello world\n Hello again!`
    ]
}

Is there a way to add line breaks in arrays? I tried mapping through the array and adding some HTML but didn't have much success there as I couldn't figure out how to separate the "Hello World" and "Hello again" messages:

const displayOutput = output.message.map((messages, id) =>
      <p key={id} className="output-message">
        {messages}
      </p>
 );

Thanks for any help!

StackUnderFlow
  • 339
  • 1
  • 11
  • 36

1 Answers1

-2

You are using a template literal, which means that linebreaks are defined by actually making a newline in the string itself.

olawrdhalpme
  • 180
  • 8