seneca-in-practice icon indicating copy to clipboard operation
seneca-in-practice copied to clipboard

Arrow functions / template strings?

Open jpclair opened this issue 8 years ago • 0 comments

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)
    })

jpclair avatar Jan 17 '17 11:01 jpclair