+ 9

How To Add 2 To 3 JavaScript Files In The Mobiles Code Playground?

Like I Have 3 Files Named app.js , question.js And quiz_controller.js Now In The Code Playground There Is Just One JS Tab Opened...!

10th Jul 2017, 10:30 PM
Hassan Ashari
Hassan Ashari - avatar
8 ответов
+ 15
You can link your files hosting them on a server, multiple services offers free hosting (Dropbox, Google Drive, Web000host) Or, easier... just put all your files in a single JS tab, including them in the order you included the files with the <script> tag, for example if you have this: <script src = "file_1.js"></script> <script src = "file_2.js"></script> ... you will put all the "file_2" content after the "file_1" content. :)
10th Jul 2017, 10:47 PM
Maz
Maz - avatar
+ 11
I got different errors. First two errors are just because of a syntax error, you wrote "return.this" rather than "return this", fix them easily. I can't see all the code now (2AM) but the last error is probably because you called: var element = document.getElementById("choices" + i); - You overwrited every time the "element" value, you should create an array and put dinamically the values inside it. - As far as i know, there is no element with id "choices" in your HTML, so... what you called?
11th Jul 2017, 12:04 AM
Maz
Maz - avatar
+ 10
Hmmm Thanks @Maz.
11th Jul 2017, 12:14 AM
Hassan Ashari
Hassan Ashari - avatar
+ 10
Yeah @Maz I Have Checked It And It Worked Really Thankfull To You Maz Just Keep It Up And You'll Be A Perfect Coder ,Web Developer And A Best Programmer.
11th Jul 2017, 12:22 AM
Hassan Ashari
Hassan Ashari - avatar
+ 6
@Maz Can You Help Me With This Code: https://code.sololearn.com/WeUOaH5jQPk6/?ref=app
10th Jul 2017, 11:38 PM
Hassan Ashari
Hassan Ashari - avatar
+ 6
And I Have Watched A Video And Then Wrote It And The Video Source Is This: https://www.youtube.com/watch?v=jvk1pFNqXaw
10th Jul 2017, 11:40 PM
Hassan Ashari
Hassan Ashari - avatar
+ 6
I Have Three Js Files And In Two It Is Showing 2 Errors 1 In Both Files One Is Named app.js And The Other quiz_controller.js 1 function Quiz(questions) { 2 this.score = 0; 3 this.questions = questions; 4 this.questionIndex = 0; 5 } 6 7 Quiz.prototype.getQuestionIndex = function() { 8 return this.questions[this.questionIndex]; 9 } 10 11 Quiz.prototype.isEnded = function () { 12 return.this.questions.length === this.questionIndex; 13 } 14 15 Quiz.prototype.guess = function(answer) { 16 if(this.getQuestionIndex().correctAnswer(answer)) { 17 this.score++; 18 } 19 20 this.questionIndex++; 21 } In This File The Error Is Like This : " quiz_controller.js:12 Uncaught SyntaxError: Unexpected token ." And The Second One Is Like This:From app'js line 51 var quiz = new Quiz(questions); The Problem Is : " Uncaught ReferenceError: Quiz is not defined at app.js:51 " Please Help Me Please...!
10th Jul 2017, 11:48 PM
Hassan Ashari
Hassan Ashari - avatar
+ 5
Thanks @Maz I'll Check It.
10th Jul 2017, 11:31 PM
Hassan Ashari
Hassan Ashari - avatar