Quick win: shout it
Write Apex · 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
toLowerCase() returns a new copy of the text in small letters. The original is not changed, so use the result.
String quietCopy(String text) {
return text.toLowerCase() + '.';
}
quietCopy('Hi') gives hi.. toUpperCase() works the same way but goes the other direction.
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 ›