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

292
Vistas
Add missing opening / closing quotation mark (fix user error)

I am trying to build a small utility in javascript that can fix user input errors. The user is supposed to enter a string in the following format:

example: object1:"key1 key2" object2:"key3 key4" object2:"key5" object2:"key6 key7" What I am trying to create is a logic that will find missing quotation marks (either opening or closing) on the keys, in case the user forgot to add it.

possible error case would be: object1:"key1 object2:"key2" which should be fixed with by adding a closing " to the key1 object.

I'm a coding beginner and I am not looking for a ready solution, but helpful suggestions how I can approach this. Thank you so much!

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If you are only concerned about the missing quotation marks and that the input string strictly only has missing quotation marks and follows your example format, one approach is to split the input in every colon character.

After that, you can loop through the array starting at the second element and check if the beginning of every string has opening quotation marks and if the characters before the object names are a quotation mark and a space. If not, add a opening/closing quotation mark.

After adding necessary quotation marks, you can just join the string back.

Again, that is if there are no other possible cases/scenarios that are needed to be checked, otherwise, you need to create a string parser that satisfies all possible cases.

about 4 years ago · Juan Pablo Isaza 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