+ 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

14th Sep 2018, 4:42 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
10 ответов
+ 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.
14th Sep 2018, 5:50 AM
Hatsy Rei
Hatsy Rei - avatar
+ 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.
14th Sep 2018, 5:53 AM
Calviղ
Calviղ - avatar
+ 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.
14th Sep 2018, 6:34 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 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
14th Sep 2018, 6:06 AM
Calviղ
Calviղ - avatar
+ 6
caused by this line btn="<li><button type='button' class='btn-warning' onclick='genLesson('"+i+"')'>"+ counter++ +"</button></li>"
14th Sep 2018, 5:25 AM
JME
+ 5
Dark Angel replace 'let' with 'var'. Might be helpful
15th Sep 2018, 6:46 AM
Rull Deef 🐺
Rull Deef 🐺 - avatar
+ 4
Calviղ uncaught error on line 36, that's what appears for me.
14th Sep 2018, 6:30 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 4
Dark Angel Its a convention but it belong to ES6 specs and all android < 5 dont support its in native WebView
15th Sep 2018, 8:08 AM
KrOW
KrOW - avatar
+ 4
Upgrade your phone, my code would work. 🤣😂
15th Sep 2018, 9:53 AM
Calviղ
Calviղ - avatar
+ 3
Rull Deef iirc let is the naming convention for loop variables that's why.
15th Sep 2018, 6:49 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar