+ 11
[SOLVED] Inexplicable error in JS.
Please check through this code and find the '}' that is causing the error, for me. I can't see the error :/ https://code.sololearn.com/WuGnJ8bHLj5d/?ref=app
10 Answers
+ 14
Replace line 35 with
btn="<li><button type='button' class='btn-warning' onclick='genLesson(\""+i+"\")'>"+ counter++ +"</button></li>"
Instead of single-quotes, I used escaped double-quotes. Spent more time than I should on this. Srsly, please consider using DOM manip instead of writing to innerHTML.
+ 9
Inspect your output with console log, you would see the errors.
https://code.sololearn.com/W2y0cbUdRf8N/?ref=app
Dont make your code complicated, use template literals for string.
+ 8
Hatsy Rei Your solution worked. Thank you!
And I am not very good with DOM manipulation because I rarely code in web and as a result I am not very accustomed.
+ 7
Modified your code using template literals for string assignment.
The string look clean and easy to understand in template literal format, don't make coding life miserable, always find clean codes to use for ease of testing and maintenance 😂
https://code.sololearn.com/W5hS705UO94c/?ref=app
+ 6
caused by this line
btn="<li><button type='button' class='btn-warning' onclick='genLesson('"+i+"')'>"+ counter++ +"</button></li>"
+ 5
Dark Angel replace 'let' with 'var'. Might be helpful
+ 4
Calviղ uncaught error on line 36, that's what appears for me.
+ 4
Dark Angel Its a convention but it belong to ES6 specs and all android < 5 dont support its in native WebView
+ 4
Upgrade your phone, my code would work. 🤣😂
+ 3
Rull Deef iirc let is the naming convention for loop variables that's why.