# Basic Algorithm Scripting - Truncate a String

Tell us what’s happening:
Hello Guys,

I find it a bit difficult to understand the “Basic Algorithm Scripting” section. When I look at the “Hints” it kind of makes sense to me but when I have to do the challenge I’m lost and don’t know where to start writing the function.

What can I do to clearly understand what I should do just by reading the question of the Test?

``````  **Your code so far**
``````
``````function truncateString(str, num) {
return str;
}

``````
``````  **Your browser information:**
``````

User Agent is: `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.102 Safari/537.36 OPR/90.0.4480.84`

Challenge: Basic Algorithm Scripting - Truncate a String

break the question to the smallest steps possible, then try to convert the single step to code before putting everything together

1 Like

I over complicate things and that cause me to be lost when I need to code it.

You can avoid analysis paralysis by just coding. I know it sounds trivial but it helps.

Even if you do not fully understand the requirement or have worked out a plan just start coding. The process alone will make you think about it differently and help you remember how you solved other similar problems and built-in methods.

Failing to solve a problem 100 times is a lot more helpful than never writing any code at all.

1 Like

Sometimes writing pseudo code can help. When i was learning and didn’t really know the correct code to write i would still break it down into rules with pseudo code that was basically the roadmap to follow. You can then look back over that pseudo code and look at it and think “hey that looks like a problem that could be solved with an if statement” and your not juggling having to figure out the code to type while also having to figure out the rules as you go.

There was a lot of times i would have a plan, only to forget about it half way through writing the code because i was googling the syntax and have to figure it all out again.

1 Like

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