node-course-v3-code
node-course-v3-code copied to clipboard
Obscure, please refactor for legibility
Hi, this is a bit obscure, specially for anyone new to Javascript, I'm not sure when you're going to make a new version, or if you can put a note there on Udemy... but maybe refactoring this to make it more legible could help your students.
if (req.query.sortBy) {
const parts = req.query.sortBy.split(':')
sort[parts[0]] = parts[1] === 'desc' ? -1 : 1
}
https://github.com/andrewjmead/node-course-v3-code/blob/b5bde8d53c1524de50ff2555ce4517015a3aefbc/task-manager/src/routers/task.js#L32
Thanks o/