Quick win: shout it
Apex basics · Beginner · 5 min · Runs in your Salesforce Developer org · Free
Scenario. A banner shows the team's slogan in capitals.
Turn text into capitals and add an exclamation mark.
What you will learn
toUpperCase() returns a new copy of the text in capital letters. The original is not changed — use the result.
String name = 'ada';
String loud = name.toUpperCase();
loud is ADA. toLowerCase() works the same way but goes the other direction. For the drill, chain the result with a + and a punctuation mark, then return it from your method.
The task
Write a method shout(String text) that returns the text in capitals with ! on the end.
Examples:
shout('hi')→HI!shout('Apex')→APEX!
Requirements:
- Use
toUpperCase()on the input. - Add
!with+. - Keep the method's name and its String input.
Starter code
String shout(String text) {
return null;
}
System.debug(shout('hi'));
System.debug(shout('Apex'));
When it passes
`shout` returns the input in capitals followed by `!` for every text the grader tries.
You write the Apex yourself. ApexSensei runs it and tells you what passed and what did not.
‹ Quick win: pick the larger number · Quick win: join a full name ›