Skip to content

Instantly share code, notes, and snippets.

Avatar

Josh Leong leodotng

View GitHub Profile
View FETCH API CALL.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style id="jsbin-css">
body {
background: #f5f5f5;
}
@leodotng
leodotng / let Promise.js
Created Aug 31, 2017 — forked from anonymous/let Promise.js
let Promise created by leodotng - https://repl.it/K9Di/2
View let Promise.js
// Here is the video https://www.youtube.com/watch?v=490Hhpqaho4
let promise = new Promise((resolve, reject) => {
//always put resolve and reject in there
let value = true;
setTimeout(() => {
if (value) {
@leodotng
leodotng / 0_reuse_code.js
Created Aug 30, 2017
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
View DOM functions&Solutions.js
// Define a function named getTextById
// The function should accept 1 parameter: id
// The function should select the element with the given id
// The function should return the element's textContent
function getTextById (id) {
let el = document.getElementById(id);
return el.innerText;
}
// Define a function named setTextById
View gist:87d36c52fd799d3a6a3e0468df512139
function waitUntil(num, str) {
//inside here we'll do a standard set time document
var promise = new Promise(function(resolve, reject) {
setTimeout(function() {
resolve(str); //whatever function that is passend in
}, num);
});
return promise;
}
@leodotng
leodotng / waitUntil.js
Created Aug 29, 2017 — forked from anonymous/waitUntil.js
waitUntil created by leodotng - https://repl.it/K6U9/1
View waitUntil.js
function waitUntil(num, str) {
//inside here we'll do a standard set time document
var promise = new Promise(function(resolve, reject) {
setTimeout(function() {
resolve(str);
}, num);
});