X648: First 10

Write a function first10(s) that returns the first 10 characters of s. If s is longer than 10 characters, just truncate it. If s is shorter, pad it with spaces at the end of the string.

Examples:

first10("012345678901234") -> "0123456789"
first10("012345") -> "012345 "

Your Answer:

Reset

Practice a different Java exercise

Feedback

Your feedback will appear here when you check your answer.