i trying actual month loop. when step through in developer tools , month[i]
== 4 doesn't assign actualmonth
checkmonth
do have assign getmonth
month[]
, try , query value?
var showcurrentmonth = function() { var getmonth = new date().getmonth(); var month = ["january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december"]; var actualmonth = ""; (var = 0; < month.length; i++) { var checkmonth = month[i]; console.log(month[i]); if (getmonth == month[i]) { actualmonth = checkmonth; } } console.log(actualmonth); } window.addeventlistener('domcontentloaded', showcurrentmonth, false);
too simple?
var showcurrentmonth = function() { var getmonth = new date().getmonth(); var month = ["january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december"]; var actualmonth = month[getmonth]; console.log(actualmonth); } window.addeventlistener('domcontentloaded', showcurrentmonth, false);
Comments
Post a Comment