FAQ: Functions - Functions for Organization

This community-built FAQ covers the “Functions for organization” exercise from the lesson “Functions”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Learn How To Code

FAQs on the exercise Functions for organization

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

During the “4/6, Functions for organization” exercise, I arrived at the last “I’d like 3 sandwiches, 2 fries, and 2 triple ice cream scoop, please!”… When making the fries without functions, I actually accidently added an extra fry. A simple mistake I really didn’t think would happen, but knew WITH the functions button, my error would not have occurred. Thank you for this basic and valuable lesson on functions.

6 Likes

Aspiring coder here. Just trying to string together what I’ve learnt. Would anyone mind telling what the difference is between a function and variable? Thank you in advance.

1 Like

They are really quite different from one another. A variable is a label to which we can assign any object, which in JavaScript includes anonymous functions, since they too are objects.

A function is an isolated block of code that we can call upon repeatedly anytime during the run session. Some functions perform heavy lifting and others perform relatively simple utility tasks.

foo = function (parameter) {
    // code body
    return expression or value
}

Above, foo is the variable to which we have assigned an anonymous function expression. We can execute (call) the function by referring to its variable name…

console.log(foo(argument))

Variables are not objects, per se. They refer to objects so that we can access them either to poll (get their data) or update (modify their data).

We learn more about functions as we move forward, but variables once we understand them to be simply labels, won’t require much review or practice. They are used all the time so one gets quite used to them.

5 Likes

That’s really helped to clear the confusion. Thank you for taking the time.

2 Likes

Functions
Functions are created to make the repetitive task quick. Humans don’t like to work on repetitive task, and also make mistakes as get bored on doing same task again and again. So repetitive task in a program are done using functions, whereas the programmer can focus on new task.
If a person keeps on doing restive task his life would spend without achieving much. Whereas if once a task is mastered by the programmer, it can be automated and can be let on machine to be done, and that’s what functions do.
Please correct if my statement is wrong,
Tx.

1 Like

Functions are design to create repetitive task to avoid doing the same task over and over while variables are labels to which we can assign object… i stand to be corrected

1 Like