0
저는 5 장의 "대부분의 적절한 가이드"연습을하고 있습니다. 내가작성시 Ramda가 정의되지 않았습니다.
var R = require('ramda');
와 Ramda을 가져온과 도우미 함수 작성했습니다 :
var _average = function(xs) {
return R.reduce(R.add, 0, xs)/xs.length;
};
잘
_average(R.map(R.prop('dollar_value'), cars));
처럼 자신의 사용 작동하지만 내가 지금처럼 구성 할 때 :
var averageDollarValue = R.compose(_average(), R.map(R.prop('dollar_value')));
다음 오류
Uncaught TypeError: Cannot read property 'reduce' of undefined
왜 이런 일이 발생하는지 설명 할 수 있습니까?
실제로 'R.map (R.prop ('dollar_value ')) (yourData)'가 실제로'undefined'가 아닌 숫자 목록을 반환하고 있습니까? –