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
Aliayub Ali
3,495 PointsHelp with this piece of code from Mozilla developer network?
Here is the code console.log(Array.from('foo')); // expected output: Array ["f", "o", "o"]
console.log(Array.from([1, 2, 3], x => x + x)); // expected output: Array [2, 4, 6]
and what is the x=>x+x inside Array.from method come from explain please.
1 Answer
Jamie Campbell
Courses Plus Student 7,603 PointsI believe you have a function (identified by '=>') inside this piece of code 'console.log(Array.from([1, 2, 3], x => x + x))', where x=> x+x will take either 1, 2, or 3 from the array, and add the number to itself to get 2,4,6.