Skip to content

Instantly share code, notes, and snippets.

View DellWard's full-sized avatar

Dell Ward DellWard

View GitHub Profile
@DellWard
DellWard / challenge1.js
Created March 30, 2018 22:00
Given two arrays, the find an integer denoting the number of integers that are BOTH multiples of all numbers in the first array and factors of all numbers in the second array.
function getBetweenTwoSets(a1, a2) {
function gcd(a, b){
while(b > 0){
var temp = b;
b = a % b;
a = temp;
}
return a
}
@DellWard
DellWard / handleChange.jsx
Last active February 25, 2018 20:28
Universal React handler
handleChange = type => event => {
const {value} = event.target;
this.setState({[type]: value});
}
//Example
<TextField value={this.state.name} onChange={this.handleChange('name')} />
@DellWard
DellWard / fetch.js
Last active January 22, 2018 20:09
//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) {