I'm trying to learn functional javascript with Ramda and I'm stuck with this. Here is the JS Bin: http://jsbin.com/kozeka/
And this is the code:
const date = new Date()
const addDays = R.add(date.getDate())
const getDate = R.compose(date.setDate, addDays)
console.log(date.setDate(date.getDate() + 6)) //Works
console.log(date.setDate(R.add(date.getDate(), 6))) // Works
console.log(date.setDate(addDays(6))) //Works
console.log(getDate(6)) //Doesn't Work
But I got this error. What I'm doing wrong?
"TypeError: Method Date.prototype.setDate called on incompatible receiver undefined
at setDate (<anonymous>)
at http://cdnjs.cloudflare.com/ajax/libs/ramda/0.22.1/ramda.min.js:6:3064
at http://cdnjs.cloudflare.com/ajax/libs/ramda/0.22.1/ramda.min.js:6:182
at kozeka.js:10:38"