I haven't declared a variable (a) like this Let a
but still it is working when i am calling my function. I wanted to know why is this working?
const mainHeading = document.querySelector("h1");
function positiveOrNegative(a) {
if (a > 0) {
mainHeading.textContent = " 'a' is a positive number";
} else if (a < 0) {
mainHeading.textContent = " 'a' is a negative number";
} else {
mainHeading.textContent = " 'a' is neither +ve nor -ve";
}
}
positiveOrNegative(-5);