FAQ: Working with Text - Review

This community-built FAQ covers the “Review” exercise from the lesson “Working with Text”.

Paths and Courses
This exercise can be found in the following Codecademy content:

FAQs on the exercise Review

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

Once again, trying to be a good student, I wanted to get my hand at the extra homework from this page:


Perhaps it is me, but I don’t feel equipped with the knowledge for obtaining random values or creating an array of string at this point in the course. I can probably figure it out on my own from knowing other languages, but I feel like that kind of exercise would be extremely daunting for an actual newcomer to coding.

Maybe it’s the goal of this extra exercise, to get us outside our comfort bubble and explore the internet for answer, but I feel like that expectation is poorly communicated. It really feels like we should already have all the knowledge for these extra exercises, but we don’t.

I’ll try to solve it on my own, but this is more a pedagogic concern for greener students than me. Let me know what you think.

Actually, it turns out it might take me many hours to understand all that is needed. Perhaps I’m taking the long way and I’m doing it the wrong way, but here’s is what my newbie brain tried to do:

      string strToRandom = "Once upon a midnight dreary, while I pondered, weak and wary.";
      int lengthStr = strToRandom.Length;
			string randomizedStr = strToRandom;
      for (int characterNumber = 0; characterNumber < lengthStr; characterNumber++)
        Random rnd = new Random();
        int randomNumber = rnd.Next(0, 2);

        bool isCap = Convert.ToBoolean(randomNumber);
        if (isCap)
          randomizedStr[characterNumber] = char.ToUpper(strToRandom[characterNumber]);

Here is what I had to learn on my own so far to make it work:
For loops
Random methods (What is a method?)
If statements

And then I was hit with something about String being read only andI had to use another class. Learning about classes seems to be way outside of the scope of this chapter, is it not?

Hi Shintenpu,

You were almost there, a small change and using a StringBuilder could make it work.
You can find info on it here:

Note, you also need to include System.Text class. This is done by adding it to the top of your code so the first two lines read:

using System;
using System.Text;

Now we have access to a StringBuilder it can be used as followed in your example.

if (isCap)
	StringBuilder sb = new StringBuilder(randomizedStr);
	sb[characterNumber] = char.ToUpper(strToRandom[characterNumber]);
	randomizedStr = sb.ToString(); 

You could also declare “StringBuilder sb = new StringBuilder(randomizedStr);” outside of the for loop after declaring randomizedStr to save declaring it several times. The result is the same though.

I do agree that this is a fair few steps above the level of the exercise and learners could feel bad after not being able to complete it whilst assuming they should have the needed info already.

This highlights another failure of this course: the concept of classes wasn’t explained yet. At the moment I undertook the course, there was no material about it.

The order of these “homework” according to the current knowledge students have don’t match.

Anyway, thank you for your answer and the time you took to write it.