FAQ: Functions - Arrow Functions

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

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

Web Development

Introduction To JavaScript

FAQs on the exercise Arrow Functions

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!

Hello, I am Claudia and I’m having a problem with the arrow function exercise: I can not find the fat arrow in my Mac Pro so I can not do the exercise. I am new to coding but have been studying javascript, the basics. Someone knows how can I get a fat arrow?
cordially,
Claudia

that is because there isn’t one key for it, there are two: equal sign (=) and greater then symbol (>). Both these keys should be present on your keyboard

2 Likes

Hi i want to know if i can use the arrow function to a nornal function or only to expression functions
thanks

Arrow functions can only be expressions, not declarations.

function foo() {
    // declared function
}

const foo = function() {
    // function expression
}

const foo = () => {
    // arrow function expression
}

E S6 Arrow Functions: Fat and Concise Syntax in JavaScript

From the above article…

Decision flow chart

3 Likes

I’ve been working on the Introduction To JavaScript course, and on this one (as well as a few others), it says I am getting it wrong even though my answer is the exact same as the solution.

Is this happening to anyone else? Is this still somehow an error on my end? Or is there somewhere I can report this issue to codecademy themselves?

1 Like

Hello, @33caitst! Welcome to the forum!
If you click on the Get Help icon in the lower right corner of the screen, you can submit a bug report to the Codecademy Team. I know it’s frustrating to click on the Solution button when your code works. There are occasions when we may have left something out of a string literal like 'Hello World!' when the SCT is expecting 'Hello, World!' Sometimes we name a variable incorrectly, or have other minor issues that aren’t errors that prevent the code from working, but don’t exactly match what the SCT for the lesson is expecting. I only say all of that to caution against submitting bug reports when you may have missed something. There definitely are legitimate bugs though, and submitting a bug report along with posting specifics to the forum are perfectly acceptable courses of action. If you do post a suspected bug to the forum, make sure to include a link to the lesson in question, so others can see if they experience the same behavior.
Happy coding!

We see a great many learners come here with very high expectations, only to have to assuage them when they meet with disappointment. These expectations can swing one of two ways:

  • expecting the course to be all encompassing and deliver a full meal deal (externalized expectation)
  • expecting ourselves to learn quickly and without making any mistakes (internalized expectation).

Nothing leads to disappointment faster then unreasonable expectations (either of the above), as we all learn by some point in life. The earlier, the better.

Bottom line, the Solution is your friend, not something to be avoided any more than using the hints. They are given for a reason. This is not a contest and there is no prize at the end of it all. Just a clearer vision, for most. Those who give up, of course are still blind to what their own potential is.

Good evening.
Is there any advantage of using the Arrow Functions method, over the other two methods?

In certain circumstances, definitely, brevity and conciseness being among the advantages. Higher order functions are another instance where the briefness makes for simplicity of both operation and reading/writing. The relaxed syntax plays right into that.

It is not a be-all and end-all, though, so we won’t be tossing the baby with the bathwater. Multiple statement functions can be just as well written in ES5 syntax if arrow syntax doesn’t simplify it to any great degree.

function multiply(a, b) {
    return a * b;
}
const multiply = function(a, b) {
    return a * b;
}
const multiply = (a, b) => a * b;

Note how the transformation from declarative to expressive to arrow expression occurs seamlessly. In situations where it is easy to transform as such, then we can leverage the simpler syntax.

1 Like