The program works perfectly on Visual Studio Code, but not sure Stackblitz. (I really need to use Stackblitz.)
The error message:
Identifier 'runTimers' has already been declared
The url Stackblitz is here => https://stackblitz.com/edit/web-platform-yaoyey?file=index.html
Thank you for your help.
2
Answers
You declared a runTimers function in both eth.js and btc.js. You have access to any functions declared in a script file you loaded before the current one.
As per your codebase in
index.html
, you have two script tags as follow:Due to this, both
btc.js
andeth.js
is imported and processed.In
btc.js
, you have following at Line 25And in
eth.js
, you have following at Line 25So, the
runTimer
is declared twice, i.e. firstbtc.js
is imported inindex.html
and the firstrunTimer
variable is declared and cleared and after thateth.js
is imported inindex.html
and it tries to createrunTimer
, which causes the error.To fix this, simply rename the variables, which would avoid conflict and fix the issue.