Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

310
Vistas
How can I save text with formatting in JavaScript?

I'm working on a Chrome Extension that has a notes page as a feature. It's not the main feature (meaning it won't be a lot of text) so I don't need to store the notes in a database, so I plan on storing the notes in LocalStorage.

Is there a way I can store this text with formatting such as new lines. For example, I want the following text:

Hello,

world.

to be saved as is, instead of "Hello,world."

about 4 years ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

To format the text, you need to use:

    const formattedText = text.split('\n').join("\\n")

To get the text back, you should use:

    const text = formattedText.split('\\n').join('\n')
about 4 years ago · Santiago Gelvez Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda