Skip to content

Instantly share code, notes, and snippets.

View Snickdx's full-sized avatar
🏠
Working from home

Nicholas Mendez Snickdx

🏠
Working from home
View GitHub Profile
@Snickdx
Snickdx / loops.js
Created July 29, 2021 05:43
For Loops
const res = 0;
for (let item of [3, 2.1, 5, 8])
res += item
res = 1;
for (let item of [3, 2.1, 5, 8])
res *= item
res = [];
for (let item of [3, 2.1, 5, 8])
@Snickdx
Snickdx / index.js
Created February 11, 2021 15:55
Async Demo
const lib = require("./lib.js");
/**
* Lib Methods
* printRed(string)
* printBlue(string)
* printYellow(string)
* printGreen(string)
* getUser()
* getUser(id)
@Snickdx
Snickdx / roundup.js
Last active February 5, 2021 20:20
roundup function
//https://www.hackerrank.com/challenges/grading/problem
function roundUp(num){
//calculate next multiple of 5 greater than num
let nextMultiple = num + 5 - (num % 5);
//get difference between next multiple and num
let difference = nextFactor - num;
//if dif > 2 or num < 38 do not round
if(difference > 2 || num < 38)
return num;
//anonymous functions
//high order functions
//observables
//String interpolation
//for in and for of
function syncSetTimeout(cb, timeout) {
return new Promise(resolve => {
setTimeout(() => {
resolve(cb()||"resolved");//cb() called after timeout
}, timeout);
});
}
(async ()=>{

Keybase proof

I hereby claim:

  • I am snickdx on github.
  • I am snickdx (https://keybase.io/snickdx) on keybase.
  • I have a public key whose fingerprint is 93A4 4076 AFD0 3AF1 3906 B159 DFC9 4CB9 1FB3 D51D

To claim this, I am signing this object:

@Snickdx
Snickdx / fun.js
Last active February 11, 2019 15:34
Functional Programming Basics in JS
//let and const block scoped
let a = 3;
const b = 5;//cannot make reassignments
//arrow function
// last line automatically returned
const add = (x, y)=> x + y;
console.log("hello");
let a = 10;
let b = 12;
a = a + b;
b = a - b;
a = a - b;
#include <stdio.h>
#define MAX 100
//SAMPLE DATA for search.in
/**
7 14
D G O O D D O D G O O D D O
O D O O G G G D O D G O G G