When did we learn 'split'?


I ended up looking at the solution for this problem because I was really unsure of how to complete it. When I looked at the solution I was surprised to find a function that I don’t recall learning (the ‘split’ function). I tried to find a previous lesson in the JavaScript curriculum where we would have learned the ‘split’ function, but I couldn’t find one. Is this problematic to have this problem here, when we technically might not have learned the ‘split’ function for strings? I only say this because I felt like I was going crazy trying to figure out what to do. Obviously, I could have googled for some help, but I figure while I’m in these lesson plans, I want to do my best to just follow the lesson plans for the time being and to go off of the knowledge they give me. A bit of a ramble about my own preferences, but I do truly wonder what someone thinks of having this problem occur in this section (Basic Algorithm Scripting), when we won’t learn about the ‘split’ function until the Functional Programming section.

  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36 Edg/89.0.774.75.

Challenge: Reverse a String

Link to the challenge:

You can solve the problem without split. You can use a simple for loop.

Hi @8LoudLoafs !

In these two algorithm sections, you will find that there are a variety of ways to solve these challenges.

For this one in particular, there are dozens of ways to solve the challenge.

A lot of those ways have not been covered in the curriculum yet. (ex. javascript split, reverse and join methods)

However, you do have all of the information needed to solve this challenge.

One way to solve this would be to use a for loop which is what @JeremyLT is talking about.

const reverseString = (str) => {
  let reversedStr = "";

  for (let i = str.length - 1; i >= 0; i--) {
    reversedStr += str[i];

  return reversedStr;

My main advice for going through the rest of the challenges is to start with the most straightforward approach possible.

You don’t have to use the built in javascript string and array methods to solve these problems.

If you are unsure if you have to use a built in method then ask the forum and we can help guide you.

Hope that helps!

1 Like

String.prototype.split() - JavaScript | MDN (mozilla.org)

Some friendly advice:
Don’t rely solely on FCC challenges for learning. Also learn to look up reference materials etc… (I also believe this would be an important skill once I’m actually working as a developer).

FCC expects that you’d have questions beyond the scope of what’s taught in their challenges, and that’s why they suggest the Read-Search-Ask method for solving challenges.

I’m currently working on the final projects for the third certification and I’ve been feeling strongly that FCC’s non-project challenges are intended to be introductory. To be able to complete the final projects, you do need to do some additional research and reading.

Looking at the solution, I see now that I tend to overcomplicate things in my head. I suppose my main frustration is that of the provided solutions on the “Hints” page, they don’t provide a ‘for loop’ solution in the way that you have provided. They jump to the split method, which according to the curriculum wouldn’t have been taught to us by then. I saw someone else say something about not relying on the curriculum for the knowledge to complete the tasks, and while that is a solid piece of advice, it doesn’t address a learners confusion (my confusion) when they go to see how something is done, only to see a solution they haven’t learned about yet. Thank you for your provided solution, I really see now how easy it was ^.^

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.