+ 1
What is wrong in my javascript code?
18 Respostas
+ 6
The blocks and brackets are out of balance.
The JavaScript console says:
"Uncaught SyntaxError: unknown: Unexpected token (143:1)"
That refers to the last line of your code from the JavaScript tab.
Where do you want to close the buildQuiz function? I see you call it after a forEach loop but don't see a clear place for you to end the function.
Indenting consistently and properly all code that is in a block the same amount more than code outside of a block would go a long way in identifying where your bracket balancing problem happens.
I see the following minor fixes:
- remove the comma in your HTML tab's script tag that tries to include quiz.js.
- in case you don't know, that quiz.js reference will be broken in Sololearn's Code Playground. This won't cause the serious problem you're asking about, though. Similar applies to your quiz.css reference.
+ 3
Please add a comment in my code where it is wrong. But please it in my code only
+ 2
I fixed most of the problems and published here:
https://joshi1983.github.io/pages/quiz/index.html
The separated HTML, CSS, and JavaScript can be found at:
https://github.com/joshi1983/pages/tree/master/quiz
Detecting correct answers doesn't work but that's a pretty small thing to leave for you to do. There are no JavaScript errors, the questions, answers all show, and you can navigate through the question slides.
I don't want to publish that on Sololearn since it mostly isn't my code.
Let me know when you have it copied so I can take it out of my repository.
+ 2
For some reason, I can't copy and replace the code directly from your Sololearn Code at https://code.sololearn.com/WSayBgk8pxS2 right now due to a bug in Sololearn's Code Playground. I can work around this by creating a brand new Sololearn Code and copy the contents of quiz.css to CSS, index.html to HTML tab, and script.js to the JS tab. Then it works.
Copy/paste the contents of the 3 files into the HTML, JS, and CSS in 24 hours and Sololearn hopefully has the bug fixed by then. Also, try making a fresh Sololearn code like I did and it might work immediately like it did for me.
Nitij, you probably don't care about this detail but if anyone else reads this and wonders, I'm pretty confident that Sololearn's Code Playground used to create a new code id automatically and copy all the code over seemlessly when hitting the "Save" button. I never expect to save changes on someone else's code but copying it to my account with my new changes is expected.
+ 1
Actually I had copied it by edureka web project.
+ 1
Please correct the code here I have remove script.js and stylesheet. Css then also it Ia not working.
+ 1
Please
+ 1
OK I was just trying I did not want to copy. I had not got the mistake yet in my code.
+ 1
But thank you for telling me and help me š¢
+ 1
I told you the first few mistakes to begin with and then you asked me to fix it so I fixed a lot more of it and shared the revised code.
Please copy my changes so my efforts don't get wasted. When I fixed a lot more, the fixes became much longer than anything I can clearly explain here. If you copy/paste all the code I shared, you can work off a much less buggy version and have fewer headaches getting it to work the way you ultimately want.
+ 1
Josh I have copied your code and paste it but it is then also coming error
+ 1
Do something please
+ 1
OK but the problem is that it is not working console is coming and questions are not seen but thanks for telling me
0
OK thank you for telling me I will try
0
Ok thanks you very much for telling me and help me
0
Hoio
0
Nitij wrote, "Josh I have copied your code and paste it but it is then also coming error"
Response:
When I check your code at https://code.sololearn.com/WSayBgk8pxS2/?ref=app I do not see any of my changes or suggestions have been implemented.
My code mostly works at:
https://joshi1983.github.io/pages/quiz/index.html
If you actually copy it, it will work like it does at the link above. I copied it into sololearn as mentioned in another comment to be sure. I mentioned in a previous comment how I had to make a new Sololearn Code to run it in my account due to a Sololearn bug in case you need to do that. If you can't copy/paste code correctly, I don't know what to say. Copy/paste should be a lot easier than programming.