Is there anyone have the same problem like me?

Not really a question but at this challenge, I really can’t find out how to solve. In the end, I have to look at the hints and find out that they use function toLowerCase and some prototype stuff. I learn all from freeCodeCamp, and until this point, I haven’t learnt about these stuff and this problem annoys me a lot :frowning:

Challenge: Title Case a Sentence

Link to the challenge:

Everyone gets frustrated. FCC can’t cover everything exhaustively and different people move at different paces through different things.

I really don’t know if toUpperCase is covered earlier. Regardless, rather than peeking at the answer, why not google “how to convert a string to upper case in javascript”?

Seriously, I cannot tell you how important googling things is for a developer. That is not cheating, that is a necessary part of the job. There is just too much stuff to memorize it all. On a “good” day, I might only have to google a dozen things. Seriously, this is a really important part of the process.

By googling, you will find your answer, you will reinforce a fundamental skill, and you will discover new resources.

Please use google before peeking at the answers. And ask the forum for a hint before googling the answers. Really, I wish they’d get rid of those - a lot of them are of questionable value and more than a few are wrong. The main value I can see for those is that after you have solved the challenge, you check to see how others have solved it.

6 Likes

Lots of the problems start to get quite hard from that point on. I found I had to consult the hints more and more often. I don’t think that is necessarily a bad thing as long as you do try your best first and make sure you really understand the solutions before moving on.

I honestly don’t know how I would have solved alot of the problems without the MDN web docs for javascript. They have all of the Methods Types etc very thoroughly documented with examples.
For example look at Objects:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object

1 Like

The important thing to keep in mind is that a lot of experience and learning is gained while doing a project (even solving a small problem).

So you read the article as much as you could, Now you need to experience the rest of the tips while coding. This means that you have to solve various challenges when coding. So you have to start a googling on that topic. Fortunately, languages like JavaScript have a lot of developers and learners, so topics are already created when you search for these.

Now in this challenge you will find that toLowerCase is the solution. Then you can even create this project for yourself to write the toLowerCase function myself. This project certainly has its challenges and you can search for any lines.

albeit If you are weak in algorithm and do not know how to move forward line by line, then I recommend that you solve simple questions to improve your algorithm and then return to this project.

Looking at the hint page is fine. The hints are just going to help you solve it yourself. You do not have to look at the solutions (don’t until you have exhausted all other options and preferably not until after you have solved it).

This was as good a time as any to learn that you need to look up information and read language documentation. Do not limit yourself to just fCC we can in no way be the only source of knowledge. Later on in the curriculum, it gets even more so true. You will have to look up documentation and articles (and that will be true for the rest of your coding life).

1 Like

Actually I can find a way to solve this problem. That is declaring an array has all uppercase string values and other array has all lowercase string values, then to compare string to each array, etc…
Of course I can google, however I thought there is a way to solve the challenge from all what I have learnt. From the beginning until now, I only peek hints to see if there are better ways to solve after I finished the challenge :frowning:

Some problems you can do just from what you learned. Sometimes you haven’t learned it. Sometimes you learned it but forgot it or misremembered it. This is all just like real life. Being good at searching for info is important for devs.

As said, you have to look things up. JS is not a big language at all in terms of what you get out of the box. But even with a small language, the curriculum cannot just go through every single individual thing the language provides. The curriculum would be enormous, and would have to mainly consist of “this is method a, this is how you use method a. This is method b, this is how you use method b”. It’s like learning a spoken language by memorising the dictionary: it’s not really going to help in the long run, you’ll just know a lot of words. Once you know there are a load of functions available to help with certain tasks, you should look up to see if there are some you don’t know that might help when you are given a new challenge.

For this, you have been shown everything you need to do the task. It is just that the language provides some functions that may make it easier, and the solutions people have submitted make use of them. You don’t have to use them, but they’ll just make your code shorter.

  • you have been shown strings, and how to join string together.
  • you have been shown loops, and how to loop through strings.
  • you have been shown how to access strings.
  • you have been shown functions.

You don’t need to use anything you haven’t been shown. So as an example that definitely only uses things you have been taught (please don’t copy this, it’s not efficient at all):

const lowercaseAlphabet = "abcdefghijklmnopqrstuvwxyz";
const uppercaseAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

function lowercaseToUppercase (character) {
  for (let i = 0; i < 26; i++) {
    if (character === lowercaseAlphabet[i]) {
      return uppercaseAlphabet[i];
    }
  }
  return  character;
}

function uppercaseToLowercase (character) {
  for (let i = 0; i < 26; i++) {
    if (character === uppercaseAlphabet[i]) {
      return lowercaseAlphabet[i];
    }
  }
  return  character;
}

function titleCase (sentence) {
  let output = "";
  output += lowercaseToUppercase(sentence[0]);

  for (let i = 1; i < sentence.length; i++) {
    if (i === 1) {
      output += uppercaseToLowercase(sentence[i]);
    } else if (sentence[i - 1] === " ") {
      output += lowercaseToUppercase(sentence[i]);
    } else {
      output += uppercaseToLowercase(sentence[i]);
    }
  }
  return output;
}
1 Like