Skip to content

Instantly share code, notes, and snippets.

Need to change colors
need to fix poster
need to fix chart. not propely scaling
@loganrun
loganrun / highLevelIdea.js
Created January 8, 2018 15:19
high level
I want tointergrate the google maps api with bit coin api's to help people find where they can use their crytpocurrency to buy items.
Will also insclude a realtime market tracker to let them know what the current exchange rate is.
'use strict';
const STORE = [
{name: "apples", checked: false},
{name: "oranges", checked: false},
{name: "milk", checked: true},
{name: "bread", checked: false}
];
$(function() {
$( "#js-shopping-list-form" ).submit(function( event ) {
const item = $("#js-shopping-list-form input[name= shopping-list-entry]").val();
$('.shopping-list').append(
$('<li>').append(
$(`<span class="shopping-item">${item}</span>`).append(
$('<div class="shopping-item-controls">').append($('<button class= "shopping-item-toggle"><span class= "button-label">check</span></button><button class="shopping-item-delete"><span class="button-label">delete</span></button>')
))));
event.preventDefault();
$('#number-chooser').on('click', function(event) {
event.preventDefault();
$(".js-results").empty();
const num = parseInt( $(event.currentTarget).find('input[name="number-choice"]').val());
for(let i =1; i<= num; i++){
if( i % 3 === 0 && i % 5 === 0){
$(".js-results").append('<div class="fizz-buzz-item fizzbuzz"><span>fizzbuzz</span></div>');
}else if( i % 3 ===0){
$(".js-results").append('<div class="fizz-buzz-item fizz"><span>fizz</span></div>');
}else if (i % 5 ===0){
@loganrun
loganrun / explainWord.js
Created November 13, 2017 17:54
explain code
The first thing the progrm does is process the raw string and removes all special characrters.
It then returns a raw string that is passed into the const words as text.
wordFrequency is initialized as an empty object and a for loop is started that will loop through the text word by word.
If the word is already in the word frequency object, it will increment by 1. If it is not, it will add it and assign
a value of 1 to it. It will then increment the counter by 1.
After the loop is finished, the program will initializes values for currentMaxKey to the key of the object wordFrequency
and set its index to 0.
currentMaxCount is set to the value of the object wordFrequency at the current index set by the currentMaxKey.
function makeStudentsReport(data) {
const result = [];
data.forEach(data => result.push(`${data.name}: ${data.grade}`));
console.log(result);
return result;
}
function createMyObject() {
const myObject = { foo: 'bar',
answerToUniverse: 42,
'olly olly': 'oxen free',
sayHello: function(){
return "hello";}
};
return myObject;
}
Scope refers to how a certain piece of information can be accessed by a computer when executing a program.
In general, scopes can be categorized as being either local or global in nature. If a variable's scope is local, than
it can only be accessed within the function that it was initially declared and will be unavailable to outside functions
or variables. By contrast, a gloabl varialble is avaiable to all parts of a program and can be accessed, and potentially altered
by all of the functions running within the program.
Global variables should be avoided because they can lead to unforeseen consequences. For instance, a result from a function that
is executed may alter the value of a global variable with this new, unexpected value being used by functions called later. Thus an
improperly scoped variable may lead to unintended results.
function fizzBuzz(countTo) {
const result = [];
for (let i = 1; i <= countTo; i++) {
if (i % 15 === 0) {
result.push('fizzbuzz');
}
if (i % 5 === 0) {
result.push('buzz');
}
if (i % 3 === 0) {