I have this if blocks where i have to test within on the same thing in both blocks :
if (download !== 'true') {
if(index == undefined){
res.json(req.doc);
}else{
res.json(index)
}
} else {
if(index == undefined){
exports.download(res, req.doc);
}else{
res.json(index)
}
}
Is there a way to refactor it in a way in which i wouldn't repeat the same thing ?
==and not===on index?