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).
- Convert all keys within an object into snake_case/camelCaseArrays and objects, Strings and parsing · basicJavaScript codingcheckednot tried
- Write a templating engine that does variables substitution and simple conditionals.Strings and parsing · advancedJavaScript codingcheckednot tried
- Implement
JSON.stringify().Strings and parsing, Arrays and objects · advancedJavaScript codingcheckednot tried - Implement
classnames— combine class names from strings, arrays, and conditional objects.Strings and parsing, Arrays and objects · reported at MetaJavaScript codingcheckednot tried - 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 - Rabin-Karp string-matching DSA problem (recurring at Microsoft).Strings and parsing, Data structures and algorithms · reported at MicrosoftJavaScript codingcheckednot tried
- 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 - 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 - 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
- What's the difference between feature detection, feature inference, and using the UA string?Strings and parsingQuizhandbooknot tried
- Have you ever used JavaScript templating? If so, what libraries have you used?Strings and parsingQuizhandbooknot tried
- Why is it called a Ternary expression, what does the word "Ternary" indicate?Strings and parsingQuizhandbooknot tried
- ES6 Template Literals offer a lot of flexibility in generating strings, can you give an example?Strings and parsing, CSS and layoutQuizhandbooknot tried
- Have you used different HTML templating languages before?Strings and parsing, HTMLQuizhandbooknot tried
- 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
- Implement
JSON.stringify(OOP-style flavor of the question has come up recently).Strings and parsing · reported at AmazonCodingno answer yetnot tried - Given a JSON object generate a file directory UIArrays and objects, Strings and parsing · reported at AmazonCodingno answer yetnot tried
- Render a directory tree given a nested JSON objectArrays and objects, Strings and parsing · reported at AmazonCodingno answer yetnot tried
- Check for balanced brackets in a string.Strings and parsing · reported at ByteDance/TikTokAlgorithmsno answer yetnot tried