Given a singular English noun in lowercase, return its plural form by applying these rules in order:
- If the noun ends with ch or sh, add es (church becomes churches, dish becomes dishes)
- If the noun ends with s, x, or z, add es (bus becomes buses, box becomes boxes)
- If the noun ends with a consonant followed by y, replace the y with ies (city becomes cities, baby becomes babies)
- If the noun ends with a vowel followed by y, add s (day becomes days, boy becomes boys)
- Otherwise, add s (cat becomes cats)
Return null for null input and an empty string for empty input.
Examples:
Input: noun = 'cat'
Output: 'cats'
Explanation: Regular noun, add s
Input: noun = 'bus'
Output: 'buses'
Explanation: Ends in s, add es
Input: noun = 'city'
Output: 'cities'
Explanation: Consonant before y, replace y with ies
Input: noun = 'day'
Output: 'days'
Explanation: Vowel before y, add s
Input: noun = 'church'
Output: 'churches'
Explanation: Ends in ch, add es
Apex Code Editor
Welcome to Lightning Challenge!
Create an Account
Sign up to track your progress, earn points, and compete with others. Your solutions will be saved automatically.
Create accountHow It Works
- • Write your solution in the code editor
- • Connect your Salesforce org to test
- • Submit to check if your solution passes
- • Use hints if you get stuck
Contest Alert
🏆 #CodeEveryDay June 2026
Contest runs June 1 - 30. Complete challenges to climb the leaderboard!
Only the 30 daily challenges shown during this contest count toward points. Earlier dailies don't carry over.