определяет accInfo как глобальную переменную, например:
var accInfo; //leave it undefined for now
form1.addEventListener('submit', () => {
//...
accInfo = acc(fname, lname,email);
//...
})
function acc(fname,lname, email){
let anotherVariableName = {fname, lname, email}
return anotherVariableName;
}
//now you can use it outside, but it will be undefined until the event listener is called
console.log(accInfo);
Вы должны изменить функцию a cc, чтобы иметь другое имя для своей переменной, хотя