Skip to content

Instantly share code, notes, and snippets.

View colevandersWands's full-sized avatar

Evan Cole colevandersWands

View GitHub Profile
function Person(name) {
this.name = name;
this.greet = function () {
console.log("i am " + this.name);
}
};
var jane = new Person("jane")
jane.greet()
function countWins(arr_of_champions, country) {
let wins = 0; // initialized to correct return type
/*
iterate through arr_of_objs
is obj.country = country?
if yes, wins++
*/
for (let obj of arr_of_champions) {
/*
gasStation: Function
args: 3
1. obj of objs:
{"gas_stationx": {"price": Number, "distance": Number}}
2. Number -> 0 <= x <= 60
3. Float -> l/100k
return: String || undefined
behavior:
find the cheapest gas station for filling your tank.
/* strategy
** constraint: use objects
0. declare variables, including object of vowls
1. convert string to object
2. delete all vowl properties
3. reconvert object to string
4. return string
*/
function removeVowels (str){ // scaffold 1
// run this in pythontutor
// ----- 1 -----
let jim = "jim";
function printer(name) {
console.log(name);
};
// pythontutor this code
var cleancalc = {
lastResult: null,
add: function (arg1, arg2) {
return arg1 + arg2;
},
operate: function (operation, arg1, arg2) {
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")
function simple_elevator(floor, button) {
let returner = 0;
let possible_result = Number(button) - floor;
// see if possible_result is allowed
// if it is, assign it to returner
return returner;
}
// https://goo.gl/XDqbKF
function hoisted(){}
var not_hoisted = function(){}
var is_it_hoisted = function huh(){}
hoisted = 0
let arr = [4, 5, 6,]
let stringnum = "4"
let temp;
for (let num of arr) {
console.log(typeof (stringnum + num))
}
// https://dmitripavlutin.com/javascriptss-addition-operator-demystified/
// https://www.safaribooksonline.com/library/view/you-dont-know/9781491905159/ch04.html