## Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

### Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today. # Arrow function not working in this practice lesson

I'm following along with this course, and trying to complete it using arrow function syntax instead of the old function syntax used in the video. I'm running two versions of the code, and they're exactly the same apart from the arrow syntax.

When I run the arrow syntax, I get an error of 'undefined'. I think this is something to do with the scope of the variables declared within the function, but I can't be sure. Any help would be greatly appreciated.

Thanks!

### Function syntax from course (works)

This logs to the console the array: [ 49, 80, 37, 68, 28, 10, 4, 89, 51, 78 ]

```/* 1. Create a function named createRandomList that uses a for loop to create an array containing 10 random numbers from 1 to 100 (use the supplied function above to generate the numbers). The function should return that array. */
function createRandomList() {
let randomList = [];
for (let i = 0; i <= 9; i += 1) {
randomList.push(random100());
}
return randomList
};

/* 2. Call the createRandomList() function and store the results in a variable named myRandomList. */
let myRandomList = createRandomList();
console.log(myRandomList);
```

### Arrow syntax (causes error, see below)

This is functionally identical, but in the arrow syntax causes an error "undefined".

```/* 1. Create a function named createRandomList that uses a for loop to create an array containing 10 random numbers from 1 to 100 (use the supplied function above to generate the numbers). The function should return that array. */
const createRandomList = () => {
var randomList = [];
for (let i = 0; i <= 9; i += 1) {
randomList.unshift(random100);
}
var randomList;
}

/* 2. Call the createRandomList() function and store the results in a variable named myRandomList. */
let myRandomList = createRandomList();
console.log(myRandomList);
``` I assume `random100` is some kind of func returning random number? In this case it is not the case with AF but with some mistypingL: You forgot parenthesis in callin `random100()` After loop you are declaring instead of returning the value