Hi I would like to pass function to another but the without affecting middle function in my code
checkUserAndStart(startFunction) - this function I want to reuse in many places (to check logged user - if is logged start function but not always with parameters)
function startInTorry(email,displayName){
$('#footer-email').html(email);
$('#InTorryUserName').html(displayName);
}
function checkUserAndStart(startFunction) {
firebase.auth().onAuthStateChanged(function (user) {
if (user) {
//user.email,user.displayName is from here
startFunction();
} else {
window.location = 'login.html'
}
})
}
$(document).ready(function () {
checkUserAndStart(function(){startInTorry(user.email,user.displayName)})
})