Files
freeCodeCamp/controllers/home.js

23 lines
586 B
JavaScript
Raw Normal View History

/**
* GET /
2014-01-07 18:15:14 -05:00
* Home page.
*/
2014-01-13 04:34:54 -05:00
exports.index = function(req, res) {
if (req.user) {
ch = req.user.challengesHash;
if (req.user.challengesHash[0] > 0) {
var max = Object.keys(ch).reduce(function(max,key){
return (max === undefined || ch[key] > ch[max]) ? +key : max;
});
nextChallenge = max + 1;
res.redirect("challenges/" + nextChallenge);
} else {
res.redirect("challenges/0");
}
} else {
res.render('home', {
2014-11-23 15:08:46 -06:00
title: 'Learn to Code and Become a Software Engineer'
});
}
2014-10-20 12:37:48 -07:00
};