This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getBetweenTwoSets(a1, a2) { | |
function gcd(a, b){ | |
while(b > 0){ | |
var temp = b; | |
b = a % b; | |
a = temp; | |
} | |
return a | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
handleChange = type => event => { | |
const {value} = event.target; | |
this.setState({[type]: value}); | |
} | |
//Example | |
<TextField value={this.state.name} onChange={this.handleChange('name')} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//fetching with query parameters | |
var url = new URL("https://geo.example.org/api"); | |
var params = {lat:35.696233, long:139.570431}; | |
Object.keys(params).forEach(key => url.searchParams.append(key, params[key])) | |
fetch(url).then(/* … */) | |
// Get request with error handling | |
fetch('https://api.github.com/users/someEndPoint') | |
.then(response => { | |
if (response.ok) { |