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!

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 October 2026 (Oct 16–31)Sponsored by FLXBL

Contest runs October 16 - 31. Complete challenges to climb the leaderboard!

Prizes 1 & 2: Salesforce certification exam voucher — won by random drawing, where every point is a ticket. see all prizes

Only the 16 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