InnerHTML printing out the entire function as a string rather than the value returned to the variable

https://codepen.io/jjwarne/pen/mBpgZJ?editors=1111

My codepen.io is above.

I cannot figure out why the variable, for instance, getMonthText is outputting the function as a string rather than outputting the returned value from the function.

var monthYear = $("month_year");
monthYear.innerHTML = getMonthText + " " + currentYear;
}

Hi @joeljwarne, to call a function (rather than passing the function itself) you have to add parentheses like getMonthText().

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.