Skip to content

Instantly share code, notes, and snippets.

View platypusrex's full-sized avatar

Frank Cooke platypusrex

View GitHub Profile
@platypusrex
platypusrex / binary.js
Created October 15, 2015 04:17
Javascript - Binary to Text Conversion
function binaryAgent(str) {
return str.split(' ').map(function(val){
return String.fromCharCode(parseInt(val, 2));
}).join('').replace(',', ' ');
}
binaryAgent("01000001 01110010 01100101 01101110 00100111 01110100 00100000 01100010 01101111 01101110 01100110 01101001 01110010 01100101 01110011 00100000 01100110 01110101 01101110 00100001 00111111");
@platypusrex
platypusrex / closure.js
Created October 15, 2015 04:15
Javascript - Arguments and Closures
function add() {
if(arguments.length > 1){
return Array.from(arguments).every(function(val){
return typeof val === 'number';
}) ? Array.from(arguments).reduce(function(prev, current){
return prev + current
}) : undefined;
}else if(typeof arguments[0] === 'number'){
var x = arguments[0];
return function(y){
@platypusrex
platypusrex / factorial.js
Created October 15, 2015 04:07
Javascript - Factorialize any number
function factorialize(num) {
if(num === 0){
return 1;
}
return num * factorialize(num - 1);
}
factorialize(5);
@platypusrex
platypusrex / palindrone.js
Last active October 15, 2015 04:05
Javascript - Check for Palindrones
function palindrome(str) {
return str.replace(/\W|_/gi, '').toLowerCase() === str.split('').reverse().join().replace(/\W|_/gi, '').toLowerCase() ? true : false;
}
palindrone('race car');
@platypusrex
platypusrex / reverseStr.js
Last active October 15, 2015 04:06
Javascript - Reverse String
function reverseString(str) {
return str.split('').reverse().join('');
}
reverseString('hello');