Skip to content

Instantly share code, notes, and snippets.

View minsooshin's full-sized avatar

Ted Shin minsooshin

  • Lunit Inc.
  • Seoul, Korea
View GitHub Profile
@minsooshin
minsooshin / bonfire-finders-keepers.js
Created November 25, 2015 02:02
http://www.freecodecamp.com/minsooshin 's solution for Bonfire: Finders Keepers
// Bonfire: Finders Keepers
// Author: @minsooshin
// Challenge: http://www.freecodecamp.com/challenges/bonfire-finders-keepers
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function find(arr, func) {
var num = 0;
num = arr.filter(function(val) {
return func(val);
@minsooshin
minsooshin / bonfire-smallest-common-multiple.js
Created November 22, 2015 05:19
http://www.freecodecamp.com/minsooshin 's solution for Bonfire: Smallest Common Multiple
// Bonfire: Smallest Common Multiple
// Author: @minsooshin
// Challenge: http://www.freecodecamp.com/challenges/bonfire-smallest-common-multiple
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function smallestCommons(arr) {
arr.sort();
var nums = [], multiple = arr[0];
for (var i = arr[0]; i <= arr[1]; i++) {
nums.push(i);
@minsooshin
minsooshin / bonfire-sum-all-primes.js
Last active November 22, 2015 04:00
http://www.freecodecamp.com/minsooshin 's solution for Bonfire: Sum All Primes
// Bonfire: Sum All Primes
// Author: @minsooshin
// Challenge: http://www.freecodecamp.com/challenges/bonfire-sum-all-primes
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function sumPrimes(num) {
var primes = [2];
function isPrime(n) {
for (var i = 2; i < n; i++) {
@minsooshin
minsooshin / bonfire-sum-all-odd-fibonacci-numbers.js
Last active November 22, 2015 04:00
http://www.freecodecamp.com/minsooshin 's solution for Bonfire: Sum All Odd Fibonacci Numbers
// Bonfire: Sum All Odd Fibonacci Numbers
// Author: @minsooshin
// Challenge: http://www.freecodecamp.com/challenges/bonfire-sum-all-odd-fibonacci-numbers
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function sumFibs(num) {
var fibs = getFibs(num),
oddFibs = [];
@minsooshin
minsooshin / bonfire-spinal-tap-case.js
Last active November 22, 2015 04:00
http://www.freecodecamp.com/minsooshin 's solution for Bonfire: Spinal Tap Case
// Bonfire: Spinal Tap Case
// Author: @minsooshin
// Challenge: http://www.freecodecamp.com/challenges/bonfire-spinal-tap-case
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function spinalCase(str) {
// "It's such a fine line between stupid, and clever."
// --David St. Hubbins
str = str.replace(/([a-z])([A-Z])/g, '$1 $2')
.toLowerCase().replace(/\s/g, '-')
@minsooshin
minsooshin / bonfire-convert-html-entities.js
Last active November 22, 2015 04:01
http://www.freecodecamp.com/minsooshin 's solution for Bonfire: Convert HTML Entities
// Bonfire: Convert HTML Entities
// Author: @minsooshin
// Challenge: http://www.freecodecamp.com/challenges/bonfire-convert-html-entities
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function convert(str) {
// &colon;&rpar;
return str.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
@minsooshin
minsooshin / bonfire-sorted-union.js
Last active November 22, 2015 04:01
http://www.freecodecamp.com/minsooshin 's solution for Bonfire: Sorted Union
// Bonfire: Sorted Union
// Author: @minsooshin
// Challenge: http://www.freecodecamp.com/challenges/bonfire-sorted-union
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function unite(arr1, arr2, arr3) {
var args = Array.prototype.slice.call(arguments);
arr1 = args.reduce(function(old, cur) {
var obj = {}, diff;
for (var i = 0; i < old.length; i++) {
@minsooshin
minsooshin / bonfire-dna-pairing.js
Last active November 22, 2015 04:01
http://www.freecodecamp.com/minsooshin 's solution for Bonfire: DNA Pairing
// Bonfire: DNA Pairing
// Author: @minsooshin
// Challenge: http://www.freecodecamp.com/challenges/bonfire-dna-pairing
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function pair(str) {
var pairing = {
"A": "T",
"T": "A",
"C": "G",
@minsooshin
minsooshin / bonfire-pig-latin.js
Last active November 22, 2015 04:01
http://www.freecodecamp.com/minsooshin 's solution for Bonfire: Pig Latin
// Bonfire: Pig Latin
// Author: @minsooshin
// Challenge: http://www.freecodecamp.com/challenges/bonfire-pig-latin
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function translate(str) {
var vowelReg = /^[aeiou]/i,
index = [];
if ((vowelReg).test(str)) {
@minsooshin
minsooshin / bonfire-search-and-replace.js
Last active November 22, 2015 04:01
http://www.freecodecamp.com/minsooshin 's solution for Bonfire: Search and Replace
// Bonfire: Search and Replace
// Author: @minsooshin
// Challenge: http://www.freecodecamp.com/challenges/bonfire-search-and-replace
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function myReplace(str, before, after) {
if ((/^[A-Z]/).test(before)) after = after.charAt(0).toUpperCase() + after.slice(1);
str = str.replace(new RegExp(before, 'gi'), after);
return str;
}