Skip to content

Instantly share code, notes, and snippets.

async function getStarWarsHeroes() {
let retryLimit = 3;
let success = false;
// API is not always returning data (500 erros happens) so we extend your tries to 3 times that explain a for loop
for (let it = 0; it < retryLimit; ++it) {
let data = await axios.get('...')
.then(response => response.json())
.then(json => {
success = true;
return json;
let config = {};
config.controller = {};
config.controller.play = function() {
console.log(this.prop);
}
config.controller.prop = "manny";
let appPlay = config.controller.play.bind(config.controller);
console.log(appPlay());
var app = {
db: {},
next_id: 0,
create: function(newThing) {
// this.db[this.next_id] = newThing;
// this.next_id ++;
if(newThing !== ''){
this.db[this.next_id] = newThing;
this.next_id ++;
console.log("THING WAS ADDED")
@1n3ffbl3
1n3ffbl3 / Solution-water-bottle.js
Last active April 23, 2018 13:54
Almost perfect water bottle solution + specs
let bottle_state = 0;
let extra_water= 0;
function read_water_level(bottle_state){
console.log(bottle_state)
};
function drink_water(bottle_fullness, thirst_score, bottle_size) {
let new_bottle_state = 0;
var app = {
db: {},
next_id: 0,
create: function(newThing) {
// this.db[this.next_id] = newThing;
// this.next_id ++;
if(newThing !== ''){
this.db[this.next_id] = newThing;
this.next_id ++;
console.log("THING WAS ADDED")
@1n3ffbl3
1n3ffbl3 / braks-n-dots.js
Created April 12, 2018 10:45 — forked from colevandersWands/braks-n-dots.js
brackets and dots
// an example to learn about dots and brackets
// below are 6 test cases that work
// try writing some that break, find out what's happening
var og = {first: 'fifty', last: 'cent'};
var curtis = 'first';
var jackson = 'last';
console.log(og.first);
@1n3ffbl3
1n3ffbl3 / gist:d094a92840ae8db1b839ddc186291761
Created April 12, 2018 10:29
HigherOrder from codewars
https://www.codewars.com/kata/coding-meetup-number-2-higher-order-functions-series-greet-developers
*/
You will be given an array of objects (associative arrays in PHP) representing data about developers who have signed up to attend the next coding meetup that you are organising.
Your task is to return an array where each object will have a new property 'greeting' with the following string value:
Hi < firstName here >, what do you like the most about < language here >?
@1n3ffbl3
1n3ffbl3 / First solution
Created April 11, 2018 09:29
Challenge from 10_04_2018
function challenge1 (a, b, c){
let base1 = Number.parseInt(a, b);
let base2 = Number.parseInt(base1, c);
return base2.toString();
}
console.log(challenge1 (10, 2, 10))