Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View colevandersWands's full-sized avatar

Evan Cole colevandersWands

View GitHub Profile
var tim = 'mit';
@colevandersWands
colevandersWands / const_des_pat.js
Created September 14, 2017 09:31
prototype inheritance, constructor design pattern
function constructor(name) {
new_obj = {};
new_obj.__proto__ = constructor.prototype;
new_obj.name = name;
return new_obj;
}
constructor.prototype = {};
constructor.prototype.age = 9;
@colevandersWands
colevandersWands / clone_vs_modify.js
Last active September 14, 2017 09:33
using Object.assign to clone an object or to modify an object
function assign_as_cloner(target_obj, source_obj) {
return Object.assign({}, target_obj, source_obj)
};
function assign_as_modifier(target_obj, source_obj) {
Object.assign(target_obj, source_obj);
};
// https://javascript.info/object#copying-by-reference
@colevandersWands
colevandersWands / terminalcalc.js
Created September 18, 2017 12:50
calc object that runs in the terminal
var calc = {
lastResult: 0000,
operate: function(operation, arg1, arg2) {
switch(operation){
case "add":
if(arg2){
calc.lastResult = calc.add(arg1, arg2);
return this.lastResult;
function isIsogram(str){
let returner = true;
let table = {};
/* iterate through string
count every time we see a letter
the second time you see a letter, return false */
/* for letter in string
count every time we see a letter
function solution(str) {
if (str.length % 2 == 0) {
let length = str.length;
for (let i = 0; i <= length/2; i++ ) {
let holder = str[i];
str[i] = str[length - i]
str[length - i] = holder;
};
}
else {
function tripledouble(num1, num2) {
var check1 = '';
var check2 = '';
if (typeof num1 !== 'number' || typeof num2 !== 'number'){
return 0;
}
var a = num1.toString().split('');
var b = num2.toString().split('');
for (var i = 0; i < a.length; i++){
let number = {
value: 0,
decrement: function() {
this.value = this.value - 1;
return this.value + 1;
},
increment: function() {
this.value = this.value + 1;
return this.value -1;
}
@colevandersWands
colevandersWands / First solution
Created April 11, 2018 10:17 — forked from 1n3ffbl3/First solution
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))
// https://github.com/Mariana88/binary-addition
// her code for binary addition
// it's so long since she constrained herself to using only strings
// this makes binaryStrAddition long,
// she had to do logical comparisons between strings
// rather than simply pulling out elements
// it doesn't work with negative numbers, but that's not important for this execise
// we looked at how she split her primary strategy (binaryAddition) into two sub-procedures