This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$amounts: (5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 75, 100); | |
$sides: (top, right, bottom, left); | |
@each $space in $amounts { | |
@each $side in $sides { | |
.margin-#{$side}-#{$space} { | |
margin-#{$side}: #{$space}px !important; | |
} | |
.padding-#{$side}-#{$space} { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="description" content="play-with-svg"> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<style> | |
#one { fill: #444; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
class ComponentName extends Component { | |
render() { | |
return (""); | |
} | |
} | |
export default ComponentName |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function debounce(func, wait, immediate) { | |
let timeOutSet = null; | |
//return function | |
return function() { | |
let args = arguments; | |
let futureCall = () => { | |
timeOutSet = null; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function shortestDistance(str) { | |
str = str.split(','); | |
let xdist = str[0] - str[2]; // find dist betwen x coords | |
let ydist = str[1] - str[3]; // find dist between y coorsds | |
// then we want to square x and y distances multiplied by each other | |
// and add the result of each | |
let output = Math.sqrt((xdist * xdist) + (ydist * ydist)); | |
// if output is not divisible by 1, let's set the decimal to two spaces. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function factorial( n ) { | |
// the end of the road | |
if ( n === 1 ) { | |
return n; | |
} | |
// otherwise: we need to multiply our number that we want to find the factorial for | |
// by calling this same function with the number less than it and continuing that all | |
// the way down to one. | |
return n * factorial( n - 1 ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function reverseStr( str ) { | |
// if the string is only 1 character in length, we return that character | |
if ( str.length === 1 ) { | |
return str; | |
} | |
// otherwise we return the product of reverse passing in the second index item with the first index item after it | |
// this constant swapping out of the second item with the first item after it eventually reverses the entire string | |
return reverseStr( str.substr( 1 ) ) + str[ 0 ]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fibonacci(num) { | |
if (num <= 1) return 1; | |
// considering the number passed in, always return the product | |
// of the two numbers lesss than it added together. | |
return fibonacci(num - 1) + fibonacci(num - 2); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// solving the fibonacci problem with memoizaion | |
// bringin the time complexity back to 0(n) and constant where as | |
// the simple recursive way of doing it was O(2^N) with O(n) space comlexity | |
function fibonacciMem(num, memo = memo || {}) { | |
if (memo[num]) return memo[num]; | |
if (num <= 1) return 1; | |
return memo[num] = fibonacciMem(num - 1, memo) + fibonacciMem(num - 2, memo); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let arrayOfIntegers = [1,2,3,4] | |
function sum() { | |
let add = (a, b) => { return a + b; } | |
return [].reduce.call(arguments, add); | |
} | |
console.log(sum(1,2,3,4)); |