Skip to content

Instantly share code, notes, and snippets.

View JimRottinger's full-sized avatar

Jim Rottinger JimRottinger

View GitHub Profile
@JimRottinger
JimRottinger / .block
Last active November 11, 2019 22:13
fresh block
license: mit
async function getRedditJSON () {
const response = await fetch('https://www.reddit.com/.json')
return response.json()
}
getRedditJSON().then((data) => {
console.log(data)
})
function getRedditJSON () {
return fetch('https://www.reddit.com/.json')
.then((response) => {
return response.json()
})
}
getRedditJSON().then((data) => {
console.log(data)
})
import React from 'react';
export interface SampleComponentProps {
firstword: string,
secondword: string
}
export interface SampleComponentState {
phrase: string
}
def sum(a=1,b=2,c=3):
return a+b+c
sum(b=5,a=10)
function sum({a = 1, b = 2, c = 3}) {
return a + b + c
}
sum({b: 10, a: 5}) // 5 + 10 + 3 = 18
function mockServerCall () {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve({
'status': 200,
'content-type': 'application/json',
'data' : {
dataOfInterest: 42
}
})
const userSettings = {nightMode: true, fontSize: 'large'}
const {
nightMode = false,
language = 'en',
fontSize = 'normal'
} = userSettings
console.log(nightMode) // true
console.log(language) // 'en'
function sumThreeNumbers(num1, num2, num3) {
console.log([num1, num2, num3]); //[4,6,10]
return num1 + num2 + num3;
}
const numbers = [4,6,10];
console.log(sumThreeNumbers(...numbers)); // 20
function sumThreeNumbers(num1, num2, num3) {
console.log([num1, num2, num3]); //[4,6,10]
return num1 + num2 + num3;
}
const numbers = [4,6,10];
console.log(sumThreeNumbers(...numbers)); //20