Strings and parsing: interview questions

Templating, serialising, tokenising and evaluating: turning text into structure and back. 19 questions from the Front End Interview Handbook. 9 have our own answer, built up from basic to advanced, with code that is proved by tests (how answers are checked).

  1. Convert all keys within an object into snake_case/camelCaseArrays and objects, Strings and parsing · basicJavaScript codingcheckednot tried
  2. Write a templating engine that does variables substitution and simple conditionals.Strings and parsing · advancedJavaScript codingcheckednot tried
  3. Implement JSON.stringify().Strings and parsing, Arrays and objects · advancedJavaScript codingcheckednot tried
  4. Implement classnames — combine class names from strings, arrays, and conditional objects.Strings and parsing, Arrays and objects · reported at MetaJavaScript codingcheckednot tried
  5. Implement a number/character pad like old flip phones — buttons where 2 = abc, 3 = def, etc. Pressing the same key cycles through letters within a short time window; after a delay, the next press appends. e.g. press 2 → a, press 2 again → b, wait 1s and press 2 → ba, press 6 → bam.Async, promises and timers, Strings and parsing · reported at MicrosoftJavaScript codingcheckednot tried
  6. Rabin-Karp string-matching DSA problem (recurring at Microsoft).Strings and parsing, Data structures and algorithms · reported at MicrosoftJavaScript codingcheckednot tried
  7. Evaluate a basic arithmetic expression string like "1+3-2" and print the output. Handle all edge cases (no BODMAS required).Strings and parsing · reported at OracleJavaScript codingcheckednot tried
  8. Given a text and a query of two words plus an integer k, return the indices in the text where the distance between the two words is ≤ k.Strings and parsing, Data structures and algorithms · reported at PalantirJavaScript codingcheckednot tried
  9. Given a stream of comments, detect inappropriate language. Requires a trie data structure.Data structures and algorithms, Strings and parsing · reported at PinterestJavaScript codingcheckednot tried
  10. What's the difference between feature detection, feature inference, and using the UA string?Strings and parsingQuizhandbooknot tried
  11. Have you ever used JavaScript templating? If so, what libraries have you used?Strings and parsingQuizhandbooknot tried
  12. Why is it called a Ternary expression, what does the word "Ternary" indicate?Strings and parsingQuizhandbooknot tried
  13. ES6 Template Literals offer a lot of flexibility in generating strings, can you give an example?Strings and parsing, CSS and layoutQuizhandbooknot tried
  14. Have you used different HTML templating languages before?Strings and parsing, HTMLQuizhandbooknot tried
  15. Build autocomplete from an input and an endpoint returning a JSON list. Update results as the input changes and support keyboard navigation.Strings and parsing, UI components · reported at AirbnbUser interface codingno answer yetnot tried
  16. Implement JSON.stringify (OOP-style flavor of the question has come up recently).Strings and parsing · reported at AmazonCodingno answer yetnot tried
  17. Given a JSON object generate a file directory UIArrays and objects, Strings and parsing · reported at AmazonCodingno answer yetnot tried
  18. Render a directory tree given a nested JSON objectArrays and objects, Strings and parsing · reported at AmazonCodingno answer yetnot tried
  19. Check for balanced brackets in a string.Strings and parsing · reported at ByteDance/TikTokAlgorithmsno answer yetnot tried