Given a singular English noun in lowercase, return its plural form by applying these rules in order:

  1. If the noun ends with ch or sh, add es (church becomes churches, dish becomes dishes)
  2. If the noun ends with s, x, or z, add es (bus becomes buses, box becomes boxes)
  3. If the noun ends with a consonant followed by y, replace the y with ies (city becomes cities, baby becomes babies)
  4. If the noun ends with a vowel followed by y, add s (day becomes days, boy becomes boys)
  5. 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 account

How 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.

Wally can't hear you

Please sign in to access the AI Assistant

Sign In