Skip to content

Instantly share code, notes, and snippets.

View leightkt's full-sized avatar

Kat Leight leightkt

View GitHub Profile
@leightkt
leightkt / IMG-0759.JPG
Last active August 30, 2018 17:12
Find a Route Thinkful Capstone App Wireframe
IMG-0759.JPG
@leightkt
leightkt / description.txt
Created August 29, 2018 14:34
Thinkful Front End Capstone Description
Help user find climbs in their area and the current weather conditions using the mountain project API and open weather map API
https://www.mountainproject.com/data
https://openweathermap.org/current
@leightkt
leightkt / catCarousel.js
Created August 6, 2018 20:47
Event Listener Drills
// where I started. . .
// $(function(){
// $(".thumbnail").click(function(event) {
// $(".hero").replaceWith($(this));
// });
// });
// where I shifted, but couldn't figure out who to identify the src of the clicked image
// $(function(){
// $(".thumbnail").click(function(event) {
@leightkt
leightkt / mostFrequentWord.js
Created August 2, 2018 16:05
grokking exercise javascript
function getTokens(rawString) {
// NB: `.filter(Boolean)` removes any falsy items from an array
return rawString.toLowerCase().split(/[ ,!.";:-]+/).filter(Boolean).sort();
}
function mostFrequentWord(text) {
//pulling each word out of the array of text
var words = getTokens(text);
//creating and empty variable
var wordFrequencies = {};
var studentData = [
{
name: 'Tim',
status: 'Current student',
course: 'Biology'
},
{
name: 'Sue',
status: 'Withdrawn',
course: 'Mathematics'
@leightkt
leightkt / deletingKeys.js
Created July 30, 2018 22:21
Object drills 1
function keyDeleter(obj) {
delete obj.foo;
delete obj.bar;
return obj;
}
var sampleObj = {
foo: 'foo',
bar: 'bar',
What is scope? Your explanation should include the idea of global vs. local scope.
Scope determines how you access variables created in JavaSctip. JavaScript has two types of scopes: global and local.
A variable created with global scope, known as a "Global," is accessible everywhere, even across files.
Every variable declared outside of a function in JavaSctip has global scope. A variable with local scope is only accessible
within the function block it was created in. It lives and dies within the function it was created in. When the function is finished,
the new variable disappears.
Why are global variables avoided?
Globals are avoided because they can create unintentional side effects and can make functions indeterminate. It can make things go wrong,
and then also be hard to debug. However, it is OK to use global variables when using a JavaScript Library like JQuery.
@leightkt
leightkt / average.js
Created July 30, 2018 01:22
Arrays and Loops Drills
// noprotect
// ^^ `noprotect` is here to prevent a bug with jsbin and for loops.
function average(numbers) {
numTotal = 0;
for (var i=0; i < numbers.length; i++) {
numTotal+= numbers[i];
}
return (numTotal)/numbers.length;
}
function accessFirstItem(array) {
return array[0];
}
function accessThirdItem(array) {
return array[2];
}
@leightkt
leightkt / errorAlert.css
Created July 25, 2018 19:33
Logic Drills
* {
box-sizing: border-box;
}
main {
padding: 50px 20px;
}
.error-report {
color: red;