0
Can you help me with JavaScript function scopes?
Hello. I am making a complex program. It's almost done, but I hit a problem. I need to call a function that is defined in different scope. I won't share the whole code here, because it has about 800 lines and looks very ugly, but I will post simplified version where functions only print a letter. How can I make thos work? https://code.sololearn.com/WMmed3NCepGK/?ref=app
3 Respuestas
+ 1
Did you mean to write `smallFunc1` on line 19?
+ 1
Sousou Schindlabua Damn! This is what happens when you try to write code while watching TV.
Thanks for your answers, but I think that in my complex version is error in something else then wrong function name. I will write here again if it still don't work.
0
//fixed
var i = 0;
window.onload = function(){
document.write("A");
smallFunc1();
function smallFunc1(){
document.write("B");
i++
bigFunc();
return;
}
function bigFunc(){
document.write("C");
if(i<3){smallFunc1();}
return;
}
}