Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Write a function to capitalize the first and last letters of each word in a string.

Medium

Problem Statement

Write a function to capitalize the first and last letters of each word in a string.

Sample Input

"hello world"

Sample Output

HellO WorlD

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
// Capitalize the first and last letters of each word function capitalizeFirstLast(str) { } console.log(capitalizeFirstLast("hello world"));
Log in or sign up to run or submit your code.Log inSign up
Input
"hello world"
Expected Output
HellO WorlD