Build the account label
The + operator joins text.
LessonRead this before the challenge.
The + sign joins pieces of text into one:
String first = 'Hello';
String whole = first + ' world';whole now holds Hello world. You can mix fixed text in quotes with variables, in any order.
Why not type the whole thing yourself? Because the variable can change. If first becomes 'Goodbye', the same line gives Goodbye world with no other edits. Typed text never updates.
The trap is the space. + adds nothing between the pieces, so the space has to go inside the quotes:
String label = 'Team:' + 'Sales';This gives Team:Sales, squashed together. Write 'Team: ' with a space before the closing quote and you get Team: Sales.
Your task
A screen that lists accounts shows each one with a label: the word Account, a colon and a space, then the company name. The label has to follow the name, so when the name changes, the label changes too.
In the starter, replace null so label is the text 'Account: ' joined to the companyName variable with +. Put the text first, with the space after the colon. Do not type the finished label as one string, and do not leave the word null anywhere in your code.
For example, when cityName is 'Austin', 'City: ' + cityName gives City: Austin because + puts the two pieces of text side by side.
String companyName = 'RidgePoint Capital';
String label = null;
String city = 'Denver';
Boolean active = true;Requirements
- Builds the label from
Account:and companyName with + - Gives label a real value instead of null
- Leaves the company name line unchanged
- Builds the label from the variable, not one typed string