Beginner JavaScript Interview QuestionsBeginnerPractical
JavaScript · Question 31
How would you reverse a string in JavaScript?
Direct answer
For a basic interview solution, convert the string to an array, reverse it, and join it; for Unicode-heavy text, discuss the limitations of naive character splitting.
A concise baseline solution is const reverseString = str => [...str].reverse().join('');. The spread creates an array of string iterator values, reverse() reverses that array, and join('') rebuilds the string.
An interviewer may also ask for a loop-based solution to test indexing and control flow. For example, build a result string from the end of the input toward the beginning.