Player's scoring using JavaScript Description:

The questions are being showed in the console tap with player's score.
It's questioning by prompt continually until the prompt input gets 'exit'.
If the answer for each question is right then player's scores are counting up.
But, if not then it shows the same question over and over until the answer is right.

var Question = function(question,answers,correctAnswer){
  this.question = question;
  this.answers = answers;
  this.correctAnswer = correctAnswer;
}
Question.prototype.score = 0;
Question.prototype.playersAnswer;

Question.prototype.logAll = function(){
  console.log(this.question);
  for(var i = 0; i &lt; this.answers.length; i++){
    console.log(i + &quot; : &quot; + this.answers[i]);
  }
}
Question.prototype.askQuestions = function(){
    Question.prototype.playersAnswer = prompt(this.question);
}
Question.prototype.checkIfRight = function (){
  if(this.correctAnswer === Question.prototype.playersAnswer){
    console.log(&quot;Correct Answer!&quot;);
    Question.prototype.score++;
    Question.prototype.logScore();
  }
  else if(Question.prototype.playersAnswer === &quot;exit&quot;){return 0;}
  else {
    console.log(&quot;Wrong! Try again :)&quot;);
    Question.prototype.logScore();
    return 'w';
  }
}
Question.prototype.logScore = function(){
  console.log(&quot;Your Score : &quot; + Question.prototype.score
  + &quot;\n---------------------------------&quot;);
}

var q1 = new Question('What is the name of the course\'s teacher?',['John','Baek','Jonas'],'2');
var q2 = new Question('Is JavaScript the coolest language in the world?',['Yes','No'],'0');
var q3 = new Question('What language are you gonna learn about after?',
                      ['C++','C','Java','Python','Node.js'],'4');
var questions = [q1,q2,q3];
function init(){
  var n = Math.floor(Math.random() * 3);
  questions[n].logAll();
  questions[n].askQuestions();
  questions[n].checkIfRight();

}

do {
  var n = Math.floor(Math.random() * 3);
  questions[n].logAll();
  questions[n].askQuestions();
  while(questions[n].checkIfRight() === 'w'){
    questions[n].logAll();
    questions[].askQuestions();
  };
}
while (q1.playersAnswer !== &quot;exit&quot;);

Can you review it for best coding practices?
In object-oriented design, the key to modelling is to figure out how your application will respond to messages. Messages can be requests for information, requests to do something, or notifications that something has happened.

In your example, the application could receive a message, "what is the next question?" After giving it some thought, you might decide that a Quiz object would be responsible for providing that information, in which case you would need Quiz class with a method to respond to the message.

function Quiz() {
...
}

Quiz.prototype.nextQuestion = function () {
...
};


Now, you don't really have any questions yet, so another obvious message that your application will have to handle is, "add this question with these answer choices and correct answer."

DO NOT simply rush and add a new method to Quiz to handle the new message; instead, you need to repeat the thought process and decide which object is best suited to respond. In this case, again it is a Quiz object because questions are needed to answer the previous message of, "what is the next question?" So, you update your Quiz class accordingly. (Along the way you create a structure to represent a question and an index to track the current question, thus enabling you to find the next question.)

function Quiz() {
    this.questions = [];
    this.index = 0;
}

Quiz.prototype.addQuestion = function (text, choices, answer) {
   this.questions.push(new Question(text, choices, answer)); 
};

Quiz.prototype.nextQuestion = function () {
    if (this.index &lt; this.questions.length)
        return this.questions[this.index++];
    return null;
};

function Question(text, choices, answer) {
    this.text = text;
    this.choices = choices;
    this.answer = answer;
}



I will skip messages that your application might have to handle in relation to player management and get to those that will require your objects to collaborate.

Say, your application receives a message, "the player has answered to this question with this answer." Going through the same thought process as before, you decide that the Quiz object will handle that, and you add a new method.

Quiz.prototype.answer = function (player, question, answer) {
...
};


However, this time, you need to check if the answer is correct as part of responding to that message. But which object can do that? Of course, the Question structure has the knowledge of correct answer, so it becomes its responsibility. Question has just been promoted from a simple structure to a full-blown class that can also respond to messages; in this case, "is this answer correct?" Therefore--

Question.prototype.isCorrect = function (answer) {
    return this.answer === answer;
};


And--

Quiz.prototype.answer = function (player, question, answer) {
    if (question.isCorrect(answer)) {
         // score some points for player
    }
}


As you can see, object-oriented design is not just finding classes and adding methods to them. You need to think about the messages and how they are handled; in other words, messages are key--NOT classes, NOT methods.

Good luck!