Here's a walkthrough for 2.14 in case anyone was wondering what the individual values look like as you work through the challenge.
Use the same
twenty20 variable, but change your variable’s contents by reassigning it to the concatenation of the following characters:
- The character at index 0 in
"Never look back."
- The character at index 3 in
"Adventure is out there."
- The character at index 14 in
"Just keep swimming."
- The character at index 1 in
"To infinity... and beyond!"
So we start out with the
twenty20 variable from the previous challenge, which is already declared for us. Then it says to "change your variable’s contents by reassigning it", meaning that we're going to use the assignment operator
= to change the value.
Then we're going to concatenate the characters from each of those strings listed. To do that the easiest way to go is to use the
charAt() method and pass in the index you're looking for.
An example would be to take the first string and use the
.charAt() method to get the character at index 0:
"Never look back.".charAt(0)
Here are the values that get printed out for each of the strings in the console:
There are multiple ways to solve the challenge. You can simply concatenate those values as follows:
twenty20 = "N" + "e" + "m" + "o"
Or just assign the full string with all the characters together:
twenty20 = "Nemo"
Or you could type out those full lines and concatenate the results and it still works well for the challenge.
twenty20 = "Never look back.".charAt(0) + "Adventure is out there.".charAt(3) + "Just keep swimming.".charAt(14) + "To infinity... and beyond!".charAt(1)
twenty20 = "Never look back." + "Adventure is out there." + "Just keep swimming." + "To infinity... and beyond!"
If you get stuck anywhere in the course, feel free to check out the provided solutions that are already available for every challenge. And don't forget to review the video lecture for this section if you're having trouble!