Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialTao Zhang
1,535 PointsIs assigning a variable to a function a form of calling a function?
The IsFieldEmpty function is not called explicitly or assigning fieldTest to this function part of the process?
" function isFieldEmpty () { const field = document.querySelector ('#info'); if (field.value === '') { return true; } else { return false; } }
const fieldTest = isFieldEmpty();
if (fieldTest === true) { alert('You need to provide info'); }"
1 Answer
Steven Parker
232,149 PointsThis isn't "assigning a variable to a function", it is assigning a variable with the value returned from a function.
But yes, the function gets called to get the value to assign to the variable.
Tao Zhang
1,535 PointsTao Zhang
1,535 PointsThanks for the clarification. are there any other ways to call a function besides using "function ();" and assigning a variable to a function?