Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Arrow Function, if you have any hint or suggestions on how to code this, i would like to thank you for the help.

Task: convert the function in the arrowfunction.js file into ES6 functions

JS:

function addFive(num) { return num + 5; } // TODO: Convert addFive() to arrow function

function divideBy(x, y) { return x / y; } // TODO: Convert divideBy() to arrow function

function logToConsole() { let msg = "MIT Coding Certificate"; console.log(msg); } // TODO: Convert logToConsole() to arrow function

1 Answer

An arrow function expression is a compact alternative to a traditional function expression. An example of an arrow function goes as follows.

// Traditional Function
function (a, b){
  let chuck = 42;
  return a + b + chuck;
}

// Arrow Function
(a, b) => {
  let chuck = 42;
  return a + b + chuck;
}

(if you still don't understand, or just want more information check out this site for a more detailed explanation.)

thank you Mr.Caleb Newell