-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
61 lines (50 loc) · 1.33 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import React from 'react';
import './App.css';
import Button from '@material-ui/core/Button';
class App extends React.Component {
constructor(props) {
super(props)
this.state = {}
}
question1 = (arr1, arr2) => {
let arr1Size = arr1.length;
let newArr = []
// loop through previous array
for (let j = 0; j < arr1Size; j++) {
// look for same thing in new array
if (arr2.indexOf(arr1[j]) === -1)
newArr.push(arr1[j])
}
console.log("Result " + newArr)
}
question2 = (a, d) => {
var arr = [];
for (var i = 0; i < a.length; i++) {
arr.push(a[i]);
};
for (var j = 1; j <= d; j++) {
arr.shift(arr.push(arr[0]));
}
console.log("Result " + arr)
}
question3 = () => {
}
render() {
return (
<div className="App">
<header className="App-header">
<div className="App-Button">
<Button variant="contained" color="primary" onClick={() => this.question1([4, 12, 6, 1, 5], [4, 6, 5])}>
Question 1
</Button>
</div>
<div className="App-Button">
<Button variant="contained" color="primary" onClick={() => this.question2([4, 12, 6, 1, 5], 2)}>
Question 2
</Button>
</div>
</header>
</div>);
}
}
export default App;