Skip to content

Instantly share code, notes, and snippets.

View colevandersWands's full-sized avatar

Evan Cole colevandersWands

View GitHub Profile

Function declaration & Function expression

Q1

console.log(square(5));
function square(n) {
return n*n;
}
  • Error
  • 25
@colevandersWands
colevandersWands / primitive-reference-types-javascript.md
Last active March 5, 2019 16:15 — forked from bishoyAtif/primitive-reference-types-javascript.md
Primitive Types & Reference Types in JavaScript

Primitive Types & Reference Types in JavaScript

An explanation of JavaScript's pass-by-value, which is unlike pass-by-reference from other languages.

Facts

  • JavaScript has 2 kinds of variable types: primitive and reference.
  • A fixed amount of memory is reserved after creation of every variable.
  • When a variable is copied, it's in-memory value is copied.
  • Passing a variable to a function via a call also creates a copy of that variable.

Primitive Types

@colevandersWands
colevandersWands / bottle-management-evan.js
Last active April 23, 2018 14:15 — forked from Mariana88/Code Review - bottleManagement Object
using model objects to manage bottles
const bottleManagement = {
bottles: {},
nextId: 0,
addBottle: function (newBottle){
newBottle.key = this.nextId
this.bottles[this.nextId] = newBottle;
this.nextId++;
return this.nextID - 1;
},
getBottle: function(id){
var app = {
db: {},
next_id: 0,
create: function(newThing) {
// this.db[this.next_id] = newThing;
// this.next_id ++;
if(newThing !== ''){
this.db[this.next_id] = newThing;
this.next_id ++;
console.log("THING WAS ADDED")
@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))
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++){