Skip to content

Instantly share code, notes, and snippets.

View AliceWonderland's full-sized avatar
:octocat:

Alice Chuang AliceWonderland

:octocat:
View GitHub Profile
@AliceWonderland
AliceWonderland / 7.3 Scope Koans.js
Created April 18, 2017 07:26 — forked from anonymous/7.3 Scope Koans.js
7.3 Scope Koans created by smillaraaq - https://repl.it/HHlS/5
var testOneMessage = "test failing";
function testOne(testOneMessage) {//every param becomes a new var local
// Test One Restrictions: Do not declare any new variable with the var keyword
// Do not reassign testOneMessage
console.log("Test one: ", testOneMessage);
}
// Run test one
testOne("test succeeding");
@AliceWonderland
AliceWonderland / 7.2 Sniper Scope.js
Created April 18, 2017 07:26 — forked from anonymous/7.2 Sniper Scope.js
7.2 Sniper Scope created by smillaraaq - https://repl.it/HHjY/13
var badGuys = function() {
var bond = '007';
//does not get redefined and does know what bond is and its value
(function oddJob() {
var AgentinScope = (bond === '007'); //true
var prediction = 'Bond stays the same because it already exists and does not get redefined';
console.log("Bond in OddJob's scope", AgentinScope, "because " + prediction);
})();
@AliceWonderland
AliceWonderland / 7.1 Counter.js
Created April 18, 2017 07:25 — forked from anonymous/7.1 Counter.js
7.1 Counter created by smillaraaq - https://repl.it/HHjJ/1
var counter = 0;
function increment(num){
counter += num;
console.log("counter: " + counter);
}
increment(2); // counter is now 2
increment(6); // counter is now 8
increment(-1); // counter is now 7
@AliceWonderland
AliceWonderland / 6.6 Sudoku.js
Created April 12, 2017 08:29 — forked from anonymous/6.6 Sudoku.js
6.6 Sudoku created by smillaraaq - https://repl.it/HGS2/42
var puzzle = [[ 8,9,5, 7,4,2, 1,3,6 ],
[ 2,7,1, 9,6,3, 4,8,5 ],
[ 4,6,3, 5,8,1, 7,9,2 ],
[ 9,3,4, 6,1,7, 2,5,8 ],
[ 5,1,7, 2,3,8, 9,6,4 ],
[ 6,8,2, 4,5,9, 3,7,1 ],
[ 1,5,9, 8,7,4, 6,2,3 ],
[ 7,4,6, 3,2,5, 8,1,9 ],
@AliceWonderland
AliceWonderland / 6.8 Finder Function.js
Created April 12, 2017 05:32 — forked from anonymous/6.8 Finder Function.js
6.8 Finder Function created by smillaraaq - https://repl.it/HGRh/3
function finderFunction(searchArray, testerFunction){
for(var i=0;i<searchArray.length;i++){
if(testerFunction(searchArray[i])){
return i;
}
}
return -1;
}
function finderFunctionArray(searchArray, testerFunction){
@AliceWonderland
AliceWonderland / 6.5 Biller Builder.js
Created April 12, 2017 05:31 — forked from anonymous/6.5 Biller Builder.js
6.5 Biller Builder created by smillaraaq - https://repl.it/HGIt/2
function biller(state){
debugger;
if(state==="NY"){console.log("ny");
var newYorkBiller=function(cost){
var finalCost=((cost*1.03)*1.09).toFixed(2);
console.log(finalCost);
};
return newYorkBiller;
}else{console.log("nj");
var newJersBiller=function(cost){
@AliceWonderland
AliceWonderland / 6.4 Function Logger.js
Created April 12, 2017 05:31 — forked from anonymous/6.4 Function Logger.js
6.4 Function Logger created by smillaraaq - https://repl.it/HGHz/1
function functionLogger(myFunc, myFuncParam){
myFunc(myFuncParam);
}
function sayHello(person){
console.log("Hello " + person +"!");
}
function sayGoodbye(person){
console.log("Bye " + person +"!");
}
functionLogger(sayGoodbye, "Patrick");
@AliceWonderland
AliceWonderland / 6.3 Median of Mean.js
Created April 12, 2017 05:31 — forked from anonymous/6.3 Median of Mean.js
6.3 Median of Mean created by smillaraaq - https://repl.it/HGEl/5
function mean(score1, score2, score3){
var totalScore=0;
totalScore+=score1;
totalScore+=score2;
totalScore+=score3;
var totalMean=totalScore/3;
return totalMean;
}
@AliceWonderland
AliceWonderland / 6.2 LongDate.js
Created April 12, 2017 05:31 — forked from anonymous/6.2 LongDate.js
6.2 LongDate created by smillaraaq - https://repl.it/HGEi/1
function longDate(myDate){
var monthArray = ["", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
var dateArray = myDate.split("/");
var month = monthArray[dateArray[0]];
var day = dateArray[1];
var year = dateArray[2];
if(year.length === 2){
if(year <= "20"){
year = "20" + year;
@AliceWonderland
AliceWonderland / 6.1 Exponentiate.js
Created April 12, 2017 05:30 — forked from anonymous/6.1 Exponentiate.js
6.1 Exponentiate created by smillaraaq - https://repl.it/HGCJ/1
function exponentiate(num1, num2){
var output=1;
for(var i=0;i<num2;i++){
output*=num1;console.log(i," ",output);
}
return output;
}
exponentiate(2, 2) // => 4
//exponentiate(3, 4) // => 81