var Question = function (que, ans, correctAns) {
this.que = que,
this.ans = ans,
this.correctAns = correctAns
};
// Creating questiosns using Constructor
var que1 = new Question(
"What is the capital of Jarkhand ",
["Ranchi", "Ahmedabad", "Raipur", "Patna"],
0);
var que2 = new Question(
"Which is the heigest score in ODI for MSD? ",
[159, 194, 183, 166],
2);
var que3 = new Question(
"How Shivgami related to Amrendra Bahubali in Bahubali movie? ",
["Mother", "Sister", "Aunty", "Wife"],
2);
// Storing all questions data in to Array
var queArr = [que1, que2, que3];
var score = 0;
// prototype method for display question
Question.prototype.displayQuestion() {
console.log(this.que);
for (var i = 0; i < this.ans.length; i++) {
console.log(i + " : " + this.ans[i]);
};
}
var num = Math.floor(Math.random() * queArr.length);
queArr[num].displayQuestion();
Hello Yagnesh.
Have a look at this section:
var Question = function (que, ans, correctAns) {
this.que = que,
this.ans = ans,
this.correctAns = correctAns
};
Are you trying to make a function or an object?
Hi Sky020!
I am using function constructor there! Never mind i got the answer ! Thanks for the reply