# When did we learn 'split'?

Hi,

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

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)