seneca-in-practice
seneca-in-practice copied to clipboard
Arrow functions / template strings?
Hi, Several exercises (and solutions) are defined with arrow functions. the exercise "decorate" for example:
seneca.decorate('stamp', (pattern) => {
console.log(Date.now(), pattern)
})
Several exercises use templates strings, the exercise "override" for example:
result.info = `${msg.left} + ${msg.right}`
It's quite cool, but it's quite confusing to have a mix between "old style" and "new style" Javascript. It's not too difficult to fix that but I don't know what behaviour do you recommend for the projet.
Solution A (classic style)
this.prior(msg, function(err, result) {
if (err) return respond(err)
result.info = msg.left + " + " + msg.right
respond(null, result)
})
Solution B (ES6 style)
this.prior(msg, (err, result) => {
if (err) return respond(err)
result.info = `${msg.left} + ${msg.right}`
respond(null, result)
})