H
H
hardterr2021-02-17 12:09:47
Programming
hardterr, 2021-02-17 12:09:47

What to do if you can’t write code with the right knowledge?

Hello, thank you for reading this, in general, I have encountered such a problem that I am not the first to study programming and, as a rule, I do not go far.

This time I lasted longer than usual, but the problems are about the same.

Now I'm learning from a list of basic lessons by type: variables, operators, functions, and so on. And most of the topics, in principle, are more than clear to me, as I think. But very often, when completing tasks, I am faced with the fact that I do not understand how to do it, although there is everything that I have already gone through.

But, if I see a solution to a particular task, then I immediately understand why certain actions were performed during the solution. But he himself, in the process of solving, did not even guess that this was possible, or he forgot certain intervals of the topic, which is necessary for solving the problem.

Tell me please, what do you think, the problem is that I spend little time on programming? Bad syntax? Or do you see the reason in something else?

Because it seems to me that if you know all the necessary topics for solving a particular problem at such a low level, you should be able to solve it.

Here is an example task:

// Объяви экспортируемую функцию getAvailableItems,
// которая принимает в качестве первого аргумента объект пользователя,
// а в качестве второго аргумента - массив объектов предметов,
// каждый элемент которого представляет из себя объект следующего вида:
// {
//	name - строка (обозначает имя предмета)
//	cost - число (обозначает цену предмета)
// }

// Пользователь представляет из себя объект следующего вида:
// {
//	name - строка (обозначает имя пользователя)
//	balance - число (обозначает баланс пользователя)
// }

// Функция getAvailableItems должна вернуть объект следующего вида:
// {
//	availableItems - массив, каждый элемент которого представляет из себя объект предмета, описанный выше
//	totalCost - число
// }

// В свойство availableItems возвращаемого объекта должен быть записан массив,
// который хранит в себе ближайшие к началу массива предметов предметы которые пользователю по карману
// Примечание: Эти предметы все вместе должны быть по карману для пользователя, а не отдельно,
// т.е. если у пользователя на балансе 500 условных единиц, то в массиве свойства availableItems
// общая стоимость предметов не должна превышать эти 500 условных единиц

// В свойство totalCost возвращаемого объекта должна быть записана сумма цен предметов,
// который суммарно по карману для пользователя. То есть это должна быть сумма цен предметов,
// записанных в массиве availableItems

Here I understand that arrays, objects, an auxiliary variable, a for...of loop, if, a function are used, I understood all this even before I saw the solution to the problem. But at the same time, I sat and could not solve the problem for an hour and just nothing came to my mind, I made a basic record, that is, I created an object that needs to be created according to the task, created an array, and that's it. But when I saw the solution, I felt so ashamed that I could not solve it, because both the answer and the task itself seemed to me painfully easy, and so it always is with everything. Although I had all the necessary knowledge to solve it.

Sorry for such a long question. I really need help, I don't want to quit programming, but I don't know how to deal with my problem.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
approximate solution, 2021-02-17
@hardterr

I am faced with the fact that I do not understand how to do it, although there is everything that I have already gone through.

This is a normal practice, it is called "not full hand."
But, if I see a solution to a particular task, then I immediately understand why certain actions were performed during the solution.

That's right, 80% of programmers write code and find solutions. Google solutions -> build solutions for your project -> do code refactoring (if required) -> get money. PS: not all the cool guys tomato seniors are different from you brains, they just have already invested from 2000 to 10,000 hours on studying material that you spent only 100-200 hours on. That's the difference.

but I don't know how to solve my problem.

Very simple. Solve typical (and non-standard) tasks (from the simplest to more complex ones) for 5-8 hours a day , and every month do a breakpoint, analyzing the path traveled. If there is no result in six months , everything is really bad, and most likely you need to download not only programming, but also the ability to think logically and critically, the ability to destructure tasks into subtasks.

R
rusrich, 2021-02-17
@rusrich

My experience:
Studied JS from lessons and official documentation.
1. He knew perfectly well what a variable is, arrays, functions, cycles, etc. It is not clear how to apply this in practice.
2. I read O'relly's book for JS beginners - I began to understand even more about variables, loops, arrays, etc. - It's not clear how to apply it in practice
3. Signed up for advanced JS, NodeJS, React - studied ES6, learned classes, understood the principles of React - how to apply it in practice - it's not clear.
4. I bought several English-language courses on udemy (Russian in the furnace), where normal real projects are created, not "there sheets" and repeated everything after the author. The first course went through and repeated everything one to one, thanks to which I understood the interaction of React with Noda, how to write an API, how to deploy and everything. The second course has already been adapted to fit your needs. As a result, I made my project and only authorization and basic methods of creating and reading remained in the course from the project. 70 percent of your code.
As a result, you need practice and you need to practice on a whole project. Then comes the understanding of why this or that method/function is needed. And a lot of theory and hell understand why it is in practice - this is the prerogative of Russian-speaking mentors.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question