Question Bank

JavaScript String Manipulation Challenges

Difficulty: Medium

Six small-but-tricky string problems: longest-word slicing, list extraction, manual reversal, palindrome checks, anagram detection, and capitalizing every word.

Question Bank
/

JavaScript String Manipulation Challenges

JavaScript String Manipulation Challenges

Six small-but-tricky string problems: longest-word slicing, list extraction, manual reversal, palindrome checks, anagram detection, and capitalizing every word.

Question Bank
Medium
JavaScript
6 questions
quiz
strings
string-manipulation
interview-prep

515 views

8

Implement generateString(str, n) that finds the first word longer than its predecessor and joins it with the next n consecutive words (no separator).

Examples

Example 1:

Input: generateString('Hello, my fullname is john doe.', 2)
Output: 'fullnameisjohn'
Explanation: 'fullname' is the first word longer than its predecessor; concat with the next 2 words ('is', 'john') without spaces.