Learnt something new today. To set default parameters, should no input be given, check if type of variable is undefined. If it is, define default parameters. Perhaps I have already learnt this but it has left my memory stores. I think this is new information to my brain though. Pretty cool! Thanks to edabit.com , my new favourite site <3 <3 <3
function moodToday(mood) {
mood = typeof mood != 'undefined' ? mood : "neutral";
return ("Today, I am feeling " + mood);
}
Comments
Post a Comment