How should I be using FCC? Longest String & .split() conundrum

How do people know about the .split() function?

I am super new to this and I am just following the FCC curriculum and I have not seen that before. Are we supposed to be using what we learned in the FCC or search for the easiest solution? I’ve been kind of struggling with the algorithms but I haven’t searched for anything because I assumed we would have everything we needed to solve the problem. The only reason I even know about the .split() function is because I wanted to know if anyone else was having the same issues I was having.

This is what I came up with based on what I have learned so far.

function findLongestWordLength(str) {
  let start = 0;    //the beginning of the word
  let finish = 0;   //the end of the word
  let current = 0;  //the length of the current word
  let long = 0;     //the length of the longest word thus far

  for (let i = 0; i < str.length; i++){ //itterate through the string


    if(str[i] === " "){         //check to see if you are at a space in the string
      finish = i;
      current = finish - start;
      start = finish + 1;
      if(current > long)
        long = current;

    if(i+1 === str.length){       //check to see if you are at the end of the string
      finish = i+1;              
      current = finish - start;
      if(current > long)
        long = current;
  return long;


findLongestWordLength("What if we try a super-long word such as otorhinolaryngology");

Any feedback on how to do it better or if I should have just searched for the best way to do it originally?

in the long run you will need to research documentation and learn new methods, but being able to solve something with just loops and if statements show good understanding of the issue and mastery of fundamentals

when you will find yourself writing stuff with many more lines, an higher level of abstraction may be needed: when you have a single method that can replace many lines of your code, will make it more readable and maintainable by others that would have to work on the same code

you did a really good job!

now you could challenge yourself in solving it in one single line! (it may be hard if you have not yet met higher order functions)
that too is not best practice, as one single line that become too long can be as difficult to read, so to avoid in projects that will need to be maintained by other people

1 Like

You will definitely need to google things outside of freeCodeCamp. There is so much to learn about and so many ways to solve problems that it would be impossible for freeCodeCamp (or any site) to cover all of it. Sometimes a freeCodeCamp challenge may have a hint to research a particular method or approach. Often you will find suggested solutions may include something that you are unfamiliar with. Some challenges will refer to topics like mathematical formulas that you’re unfamiliar with. When that happens I definitely encourage you to research the known math solution and then figuring out how to implement it as code rather than reinventing the math.

As you showed in this solution, problems can be solved with the correct application of fundamental concepts. This is excellent problem solving.

freeCodeCamp provides structure and guide rails for learning web programming, but it doesn’t do it all.

1 Like

Thank you for your reply!

I am just feeling kind of lost, like I am missing something. I want to learn all I can and hopefully get a job relatively soon, but it seems still so far away. I have the responsive web design cert, but every job opening seems to want WAY more than I currently know.

Whenever people talk about trying to get a job quickly, I feel compelled to burst their bubble a bit and remind them that the traditional path to a job in programming is four years of full time university study including multiple professional internships. Of course 189 lessons and 5 small projects isn’t enough. I’m not trying to imply that a degree is necessary, or even the best path for everyone. I’m reminding you that when you are applying for jobs, you are trying to prove that you are at least as qualified for the job as those other applicants. People really do achieve success from learning for free on their own. They put in an ass-ton of work to do it.

1 Like

Right… That is a good reality check. Thank you. :+1:

I’m just anxious to get going in a field I actually enjoy.

I went to school for 5 years to be a band director and only taught in public schools for a couple of years before I couldn’t take it anymore.

Now I wait tables again.

I know it will take a lot of work to get where I want to go, but I would love to be earning a living doing something in the field while still learning. I was hoping to land a junior front end job when I finished the JS and Data Structure certification.

Do you think that’s an unreasonable expectation?

I don’t think that is a reasonable expectation. You will need to demonstrate your skills by building many projects and then picking your best ones to highlight to prospective employers. The FCC curriculum is a starting point. You will need to learn so much more even for a Junior position. You can validate this yourself by going to your favorite jobs site and seeing what the requirements are for a Junior position.

1 Like

You don’t think the projects that are part of the certification would be enough?

It really depends. It depends on how deeply you go into your projects: how much you learn and can make good use of beyond the minimum requirements, how strong a portfolio you can build in that time. It depends on what jobs are available in your area - or, if you plan to freelance, how able you are to work that hustle.

Since your goal is to find work as a web developer, I think it’s a good idea to keep tabs on the jobs that are available and what their expectations are. If any have coding tests as part of the application, challenge yourself to see how close you are to being able to complete those tests even if you know you’re not 100% ready. The job postings you can find may give you something concrete to measure yourself against. Look at job postings and ask yourself “Do I think I can prove that I can do that?”

The more you know, the better you know it, and the more you can demonstrate that knowledge - the more jobs you’ll be ready for. I can’t make a guess of at what point you will qualify for enough jobs to get one.

1 Like

I am very appreciative of your honest feedback.

I had a customer a couple of weeks ago that I spoke to about my aspirations, and they were in the industry (I think they might have worked for a recruiting agency) and said I should contact them and they would put me in touch with someone who would do fake interviews/coding tests.

I’ve been waiting until I felt more ready, but it sounds like I should go ahead and try to set that up to see how far I still have before I’m job ready.

I’m in the Dallas area, so there are a ton of opportunities near me.