Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

300
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!