// A function that returns a function is called a higher-order function.
/*
In this example, we are returning a function from another function -
We can return a function because functions in JavaScript are
treated as values.
*/
function sayHello() {
return () => {
console.log("Hello!");
}
}
//Syntactic Sugar for a ForEach loop below; this is part of a form validation
//and basicly goes through every element in the form and logs the id for said
//element.
function checkRequired(inputArr) {
// |
//? V High Order Array Method
inputArr.forEach(function (input) {
console.log(input.id)
});
}
//! Event Listeners --> This is a higher order functon
form.addEventListener('submit', function (e) {
e.preventDefault();
//passing in array of arguments to be checked
checkRequired([username, email, password, password2]);
});