Skip to content

Commit 2183702

Browse files
author
smishra38@sapient.com
committedJul 27, 2017
Moving data to an external file
1 parent a67415a commit 2183702

File tree

2 files changed

+46
-39
lines changed

2 files changed

+46
-39
lines changed
 

‎src/data.js

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
var data =
2+
[
3+
{
4+
question: "What is the Javscript compiler name in Google Chrome?",
5+
options: ["Chrome V6", "Chrome V7","Chrome V8","Chrome V9"],
6+
key: "Chrome V8"
7+
},
8+
{
9+
question: "How can you detect the client's browser name?",
10+
options: ["navigator.userAgent", "navigator.browser","browser.appName" ,"app.browserName"],
11+
key: "navigator.userAgent"
12+
},
13+
{
14+
question: "Nearly all objects in JavaScript are instances of which of the following?",
15+
options: ["Object", "_proto_","Prototypes" ,"DOM"],
16+
key: "Object"
17+
},
18+
{
19+
question: "Which of the following is a correct way to empty an array?",
20+
options: ["arrayName.empty();", "arrayName.splice(0, arrayList.length);","arrayName = null;" ,"arrayName = Obejct.empty();"],
21+
key: "arrayName.splice(0, arrayList.length);"
22+
},
23+
{
24+
question: "Which of the following is not a React Component Lifecycle method?",
25+
options: ["componentWillUpdate ", "componentDidUpdate ","componentWillUnmount " ,"componentGoingToUpdate"],
26+
key: "componentGoingToUpdate"
27+
},
28+
{
29+
question: "In Experience Technology world, What does MEAN stand for?",
30+
options: [ "Mongodb, ES6, Angularjs and Node",
31+
"Mongodb, Ember, Angularjs and Node" ,
32+
"Mongodb, Express, Angularjs and Node",
33+
"Meteor, Express, Angularjs and Node"],
34+
key: "Mongodb, Express, Angularjs and Node"
35+
},
36+
{
37+
question: "In which of the following React Component Lifecycle methods, React refs do not work?",
38+
options: ["componentWillMount", "componentDidMount ","componentWillUnmount " ,"componentDidUpdate"],
39+
key: "componentWillMount"
40+
}
41+
];
42+
43+
module.exports = data;

‎src/index.js

+3-39
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import React from 'react';
22
import ReactDOM from 'react-dom';
33
//import PropTypes from 'prop-types';
4+
var data = require('./data.js');
45

5-
function shuffleArray(array) {
6+
var shuffleArray = array => {
67
let i = array.length - 1;
78
for (; i > 0; i--) {
89
const j = Math.floor(Math.random() * (i + 1));
@@ -15,13 +16,12 @@ function shuffleArray(array) {
1516
class Quiz extends React.Component{
1617
constructor(props, context) {
1718
super(props, context);
18-
this.refreshQuestion = this.refreshQuestion.bind(this)
19+
this.refreshQuestion = this.refreshQuestion.bind(this);
1920
this.state = {
2021
change:false
2122
}
2223
}
2324
refreshQuestion(){
24-
console.log(this);
2525
this.setState({
2626
change:true
2727
})
@@ -97,42 +97,6 @@ class Answer extends React.Component{
9797

9898
}
9999

100-
var data = [
101-
{
102-
question: "What is the Javscript compiler name in Google Chrome?",
103-
options: ["Chrome V6", "Chrome V7","Chrome V8","Chrome V9"],
104-
key: "Chrome V8"
105-
},
106-
{
107-
question: "How can you detect the client's browser name?",
108-
options: ["navigator.userAgent", "navigator.browser","browser.appName" ,"app.browserName"],
109-
key: "navigator.userAgent"
110-
},
111-
{
112-
question: "Nearly all objects in JavaScript are instances of which of the following?",
113-
options: ["Object", "_proto_","Prototypes" ,"DOM"],
114-
key: "Object"
115-
},
116-
{
117-
question: "Which of the following is a correct way to empty an array?",
118-
options: ["arrayName.empty();", "arrayName.splice(0, arrayList.length);","arrayName = null;" ,"arrayName = Obejct.empty();"],
119-
key: "arrayName.splice(0, arrayList.length);"
120-
},
121-
{
122-
question: "Which of the following is not a React Component Lifecycle method?",
123-
options: ["componentWillUpdate ", "componentDidUpdate ","componentWillUnmount " ,"componentGoingToUpdate"],
124-
key: "componentGoingToUpdate"
125-
},
126-
{
127-
question: "In Experience Technology world, What does MEAN stand for?",
128-
options: [ "Mongodb, ES6, Angularjs and Node",
129-
"Mongodb, Ember, Angularjs and Node" ,
130-
"Mongodb, Express, Angularjs and Node",
131-
"Meteor, Express, Angularjs and Node"],
132-
key: "Mongodb, Express, Angularjs and Node"
133-
}
134-
]
135-
136100
// Quiz.PropTypes = {
137101
// books: PropTypes.bool.isRequired,
138102
// }

0 commit comments

Comments
 (0)
Please sign in to comment.