0

Why f is not defined?

I defined a function with name f inside window.onload . But when I call this function console says function not defined. https://code.sololearn.com/Wjq9jObim7Sh/?ref=app

28th Apr 2021, 8:51 AM
˜”*°•.˜”*°• Mohan 333 •°*”˜.•°*”˜
˜”*°•.˜”*°• Mohan 333 •°*”˜.•°*”˜ - avatar
8 Answers
+ 1
Mohan 333 Don't write function inside another function if you are calling that function from an element. https://code.sololearn.com/W1iOV2YJ8sOV/?ref=app
28th Apr 2021, 9:03 AM
A͢J
A͢J - avatar
+ 1
Mohan 333 clearInterval, setInterval, setTimeout are default functions in JavaScript like console.log
28th Apr 2021, 9:12 AM
A͢J
A͢J - avatar
0
🅰🅹 🅐🅝🅐🅝🅣 But how the move function is working?
28th Apr 2021, 9:04 AM
˜”*°•.˜”*°• Mohan 333 •°*”˜.•°*”˜
˜”*°•.˜”*°• Mohan 333 •°*”˜.•°*”˜ - avatar
0
How to make f() works?
28th Apr 2021, 9:05 AM
˜”*°•.˜”*°• Mohan 333 •°*”˜.•°*”˜
˜”*°•.˜”*°• Mohan 333 •°*”˜.•°*”˜ - avatar
0
Mohan 333 Because you are calling move function inside window.onload function so it is working but you are calling function f from outside so it will not work because you cannot work with nested function like that.
28th Apr 2021, 9:08 AM
A͢J
A͢J - avatar
28th Apr 2021, 9:13 AM
˜”*°•.˜”*°• Mohan 333 •°*”˜.•°*”˜
˜”*°•.˜”*°• Mohan 333 •°*”˜.•°*”˜ - avatar
0
Mohan 333 clearInterval is a built in function that takes a function/call back and time in ms.with the interval of time in ms it will be continued to call the function.
30th Apr 2021, 2:50 AM
sid
sid - avatar
- 1
Ok. But how the clearInterval works?
28th Apr 2021, 9:11 AM
˜”*°•.˜”*°• Mohan 333 •°*”˜.•°*”˜
˜”*°•.˜”*°• Mohan 333 •°*”˜.•°*”˜ - avatar