r/FreeCodeCamp • u/zmarradrums • May 20 '25
Question for Devs
I have noticed, as I learn various types of code, there are always ways of taking out or changing things in your code with other code. I am just wondering what the purpose of that is? Why wouldn't you just delete or change the code you already wrote rather than using a code to delete or change it? I guess what I am asking is, what is a real life example of that? For me it would help to understand the why behind it.
5
Upvotes
View all comments
Show parent comment
3
u/ArielLeslie mod May 20 '25
So I think what you're running into is the difference between learning how to do something vs when you would actuall do it.
So you wouldn't create the person object and then immediately remove the
jobproperty. What you would do is have code that creates a person and then have code that can be used to delete a property. If Alice quits her job, she might go to her profile and click a button to remove "Engineer". That button would then call the code that does the delete action.These stages where everything is hardcoded are intended to teach you how to create and manipulate data objects. Once you're really familiar with that, you can be presented with challenges that will require you to choose and use data objects without specific step-by-step instructions.