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 trialnathanielcusano
9,808 PointsCould you have written the functions as arrow functions.... such as
var like = (thing) => `I like ${thing}`;
var love=(thing)=> `I love ${thing}`;
2 Answers
hum4n01d
25,493 PointsYes! You could do it like this:
let like = thing => `I like ${thing}!`
Notice that I changed var
to let
and removed the optional parentheses around the parameter
nathanielcusano
9,808 Pointsexcellent thanks
hum4n01d
25,493 PointsNo problem!
Leoben 1987
1,574 PointsIs it better practice to use const for functions? (assuming we don't want to overwrite them later)
Franklyn Roth
16,770 PointsYou could even combine both of them into 1 arrow function!
let likeLove = (thing1, thing2) => `I like ${thing1}, but love ${thing2}`;
console.log(likeLove(`beer`, `sleeping`));
Franklyn Roth
16,770 PointsFranklyn Roth
16,770 PointsYou could even combine both of them into 1 arrow function!