Hi campers, this challenge has taken from me a long time to solve, here it is:

https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/functional-programming/use-the-reduce-method-to-analyze-data/

finally this is my solution :

```
// Add your code below this line
var average=watchList.map(function(item){
return {Director:item.Director,rating:item.imdbRating};
}).filter(function(item){
if(item.Director==="Christopher Nolan"){
return {Director:item.Director,rating:item.imdbRating};
}
}).map(function(value){
let num=Number(value.rating);
return num;
}).reduce(function(sum,currentValue,index,arr){
sum+=currentValue;
if(index===arr.length-1){
return sum/arr.length;
}else {
return sum
}
});
var averageRating=average;
// Add your code above this line
console.log(averageRating);
```

this worked well

but I donâ€™t know why in reduce method I couldnâ€™t use just if statment without else statment :

```
var average=watchList.map(function(item){
return {Director:item.Director,rating:item.imdbRating};
}).filter(function(item){
if(item.Director==="Christopher Nolan"){
return {Director:item.Director,rating:item.imdbRating};
}
}).map(function(value){
let num=Number(value.rating);
return num;
}).reduce(function(sum,currentValue,index,arr){
sum+=currentValue;
if(index===arr.length-1){
return sum/arr.length; //here it retuns NAN
}
});
```

why it retuns NAN ,and my second question did I use a long approach for this challenge .

thank you guys in advance.