I stored the function in the variable "a" and I was expecting it to return "hello" in the html but it instead returned the whole function as a string.
When calling the function using the variable plus parantheses "a()" it outputted the string "hello" in the html, which is what I wanted to do. Can anyone explain why this works? Thank you :)
let a = function greetings() {
let b = "hello";
return b;
};
document.getElementById('hi').innerHTML = `This is the output without the parentheses: <br> ${a}
<br><br>
This is the output with the parentheses: <br> ${a()}`;
<p id='hi'>...</p>