Skip to content

Instantly share code, notes, and snippets.

@camckin10
camckin10 / scope-challenge
Last active December 5, 2016 15:49
Challenge: In Your Own Words
What is scope? Your explanation should include the idea of global vs. local scope.
With variables, there are two types: global and local. A global scope is a variable that is declared in the main body source of your code.
For example, imagine you have an JS file that has a variable declared *before* there is a function. Your global scope
would look like this: var schoolName="Island"; A local scope is a variable that has been declared and is *only* accessible through a set of
instructions, such a function. For example, if you were to have a JS file, and in this JS file there is a function called "mySchool."
Then your local scope in your JS file would look like this: function mySchool()
var schoolNames="Island";
Why are global variables avoided?
Global variables are avoided because they can make your code extremely messy. Global variable or scope that is declared can be available
@camckin10
camckin10 / object-drills.js
Created December 7, 2016 02:34
Object basics drills
//object creator
function createMyObject () {
return {
foo: 'bar',
answerToUniverse:42,
'olly olly': 'oxen free',
sayHello: function () {
return ('hello');
}
}
@camckin10
camckin10 / thinkful-notes.js
Last active February 4, 2017 02:53
thinkful notes
//thinkful notes with pedro dec.8.16
function mostFrequentWord(words) {
// count = {};
// count['apple'] = 1;
// count['apple'] = 3;
// count['apple'] = count['apple'] + 3;
// This would give me an object like:
// var count = {
// apple: 6
@camckin10
camckin10 / advancedobjects-drills.js
Last active December 27, 2016 18:57
advancedobjects-drills.js
//most frequent word
function mostFrequentWord(words) {
var count = {
orange:1,
apple:3,
kiwi:2
var biggestWord = "";
var biggestCount=0;
object.jetys(count).forEach(
@camckin10
camckin10 / pedro-drills.js
Last active January 14, 2017 00:15
pedro-drills.js
//word counter drill
function wordCounter(word_list) {
}
// Should return { apple: 3, orange: 1 }
wordCounter(['apple', 'apple', 'apple', 'orange']);
function wordCounter(word_list){
var fruit = {};
@camckin10
camckin10 / drilsanswers.js
Last active February 21, 2017 02:24
Drills Answers
EXAMPLE PROBLEM W/MICHAEL
//var number_list = [1,3,6,6,7,8,2]
function problem(number_list){
//var number_list = [4,6,10,12]
var sum_counter = 0
for(var i = 0; i <number_list.length; i++) {
var value = number_list[i]
sum_counter = value + sum_counter
@camckin10
camckin10 / objectdrills2.js
Last active March 15, 2017 01:09
objectdrills2.js
1.)make student report
function makeStudentsReport(data) {//function name w/ argument
var answers = [];//create an empty array
for (var i=0; i<data.length; i++) {//for loop that measures length
var reports = data[i];//create another variable that has the argument
//inputting the for loop variable?
answers.length(reports.name + reports.grade);//ask the computer to
//print the length of the answers
}
return answers;//returning the array with proper information
1.) Link Here, Link There
<main>
<h2>1. Open this Link THERE!</h2>
<p><a href = "#" target="https://www.stackoverflow.com">Stack Overflow </a></p>
--> Replace this text with a link that links to the Stack Overflow website and opens in a new tab.
<h2>2. Click a link to send email!</h2>
<p> <a href= "mailto:username@site.org?subject=link%20here%20link%20there%20linkhere,linkthere">Blank Email</a></p>
</main>
---> Replace the text in this paragraph that opens a blank email with the subject line, link here, link there
@camckin10
camckin10 / CSSDrills
Last active March 22, 2017 00:39
CSS Drills
1.) Drill 1: Width, Height, Color, Border
In this drill, you’ll add classes to the two divs to create a blue box and a red box, as described in the code comments and paragraphs in the code pen. To complete this drill, you'll need to use the following CSS properties:
background-color
margin-bottom
border
SOLUTION:
html
<main>
@camckin10
camckin10 / CSSDrillspart2
Last active March 27, 2017 19:36
Target Practice CSS Drills prt 2
1.) To complete the drill for element selectors below, you'll need to target section elements and h1 elements. Specifically:
Write one ruleset for sections that gives them a bottom margin of 90px
Write one ruleset for header elements that sets font-family to Helvetica.
HTML:
<main>
<section>
<header>
<h1>Really important section header</h1>