Skip to content

Instantly share code, notes, and snippets.

View chasingSublimity's full-sized avatar
👨‍🎓

Blake Sager chasingSublimity

👨‍🎓
View GitHub Profile
var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
if (computerChoice < 0.34) {
computerChoice = "rock";
} else if(computerChoice <= 0.67) {
computerChoice = "paper";
} else {
computerChoice = "scissors";
} console.log("Computer: " + computerChoice);
@chasingSublimity
chasingSublimity / drill1.js
Created November 3, 2016 16:23
String Drills -- FEWD-001
function wisePerson(wiseType, whatToSay) {
// your code here
var wiseQuote = 'A wise ' + wiseType + ' once said: \"' + whatToSay + '\".';
console.log(wiseQuote);
return(wiseQuote);
};
/* From here down, you are not expected to
understand.... for now :)
@chasingSublimity
chasingSublimity / numberDrill1.js
Created November 3, 2016 16:45
numberDrills.js
function computeArea(width, height) {
// your code here
area = width * height;
return(area);
};
/* From here down, you are not expected to
understand.... for now :)
@chasingSublimity
chasingSublimity / drill1.js
Created November 4, 2016 00:22
logicDrills
function doTrafficLights() {
var activeLight = getActiveLight();
// your code will replace this call
// to `console.log()`
if (activeLight === "red") {
turnRed();
} else if (activeLight === "green") {
turnGreen();
} else {
@chasingSublimity
chasingSublimity / drill1.js
Created November 5, 2016 17:59
arrayDrills
function max(numbers) {
// your code here
for (i = 0; i < numbers.length; i++) {
var max = 0;
if (numbers[i] > max) {
max = numbers[i];
};
};
return(max);
};
@chasingSublimity
chasingSublimity / question1.txt
Created November 5, 2016 20:57
Global Scope Variable Questions
-- What is scope? Your explanation should include the idea of global vs. local scope.
Scope refers to the effective domain of a given variable. In Javascript EC5, variables either have 'global' or 'local' scope.
When variables have 'local scope', they are only accessible within that particular scope. For instance, if, within a given function, you defined a variable like so:
var foo = "bar";
That variable would only be accessible within the function it was called. If, outside of said function, one tried:
console.log(foo);
@chasingSublimity
chasingSublimity / drill1.js
Created November 6, 2016 00:10
Object Basic Drills
function createMyObject() {
// your code here
var myObject = {
foo: 'bar',
answerToUniverse: 42,
'olly olly': 'oxen free',
sayHello: function() {
return("hello");
}
}
@chasingSublimity
chasingSublimity / drill1.js
Last active November 29, 2016 15:37
Advanced Object Drills
function mostFrequentWord(words) {
// your code here
// `words` is an array of strings.
var wordFreq = {};
for (var i = 0; i < words.length; i++) {
if (words[i] in wordFreq) {
wordFreq[words[i]]++;
} else {
wordFreq[words[i]] = 1;
@chasingSublimity
chasingSublimity / drillLinks
Last active November 30, 2016 22:22
Event Listener Drills
@chasingSublimity
chasingSublimity / links.txt
Created December 8, 2016 00:25
Quiz App Wireframe CodePen links