From fe0dca1d1ce12191794bbd6692bf4d18eb7352d6 Mon Sep 17 00:00:00 2001 From: Jody Smith Date: Fri, 12 Jan 2018 17:44:35 -0500 Subject: [PATCH 1/8] Return and Exceptions paper & problem.js --- paperproblems/HOF/problem1.txt | 9 +++++++ paperproblems/HOF/problem2.txt | 6 +++++ paperproblems/HOF/problem3.txt | 6 +++++ paperproblems/HOF/problem4.txt | 7 ++++++ paperproblems/exceptions/problem1.txt | 2 +- paperproblems/exceptions/problem2.txt | 2 +- paperproblems/return/problem1.txt | 2 +- src/exceptions/problem1.js | 34 +++++++++++++++++++++++++-- src/return/problem1.js | 14 +++-------- 9 files changed, 66 insertions(+), 16 deletions(-) diff --git a/paperproblems/HOF/problem1.txt b/paperproblems/HOF/problem1.txt index 5985535..3e6092d 100644 --- a/paperproblems/HOF/problem1.txt +++ b/paperproblems/HOF/problem1.txt @@ -1,7 +1,16 @@ +/* My answers + +It has 2 parameters the first is a variable that is assigned an array the second is the function to be performed on it, so array, function (shocking since this is the HOF question). + +what does it do, it loops though each item of the array and if isOdd returns all of the Odd characters and isEven will return all of the even numbers + +*/ + Someone has given you a function called filter You don't know what it does, but there are clues at the bottom of this file Use these clues to describe what filter is. Specifically: + - How many parameters does it have - What are the types of the parameters - What does it do? diff --git a/paperproblems/HOF/problem2.txt b/paperproblems/HOF/problem2.txt index 7215f54..450d3e2 100644 --- a/paperproblems/HOF/problem2.txt +++ b/paperproblems/HOF/problem2.txt @@ -1,3 +1,9 @@ +/* + +map has two parameters you pass it an array and a function to perform on the array, if you pass it a numbers array and either double or triple it will do math, if you pass it the strings array with up or down it will turn all of the letters to upper or lower case. + +*/ + Someone has given you a function called map You don't know what it does, but there are clues at the bottom of this file Use these clues to describe what map is. diff --git a/paperproblems/HOF/problem3.txt b/paperproblems/HOF/problem3.txt index 46f2ead..bf5e936 100644 --- a/paperproblems/HOF/problem3.txt +++ b/paperproblems/HOF/problem3.txt @@ -1,3 +1,9 @@ +/* man I hate this abc shit + +f(k) => f(g) where g is k so returns k(3,5), so i is 3 and j is 5 returns 3+2+5*2, 5*2 is 10 + 5 = 15 + +*/ + What is the output of this program? Don't cheat by running it! function k(i, j) { diff --git a/paperproblems/HOF/problem4.txt b/paperproblems/HOF/problem4.txt index 6441398..6750344 100644 --- a/paperproblems/HOF/problem4.txt +++ b/paperproblems/HOF/problem4.txt @@ -1,3 +1,10 @@ +/* + +we pass f( k and m), k and m become g and h, return k(m, 1, 4), k(f=m,i=1, j=4) becomes return m(1+2) + 4 * 2, gets to m(3) 6 + 8 = 14 + + +*/ + What is the output of this program? Don't cheat by running it! function m(x) { diff --git a/paperproblems/exceptions/problem1.txt b/paperproblems/exceptions/problem1.txt index b39b619..9d71812 100644 --- a/paperproblems/exceptions/problem1.txt +++ b/paperproblems/exceptions/problem1.txt @@ -1,4 +1,4 @@ -What does the following print out? +What does the following print out? - 500. g() try's to run f, f is an empty function and falis throwing 500, g catches the err and then console logs it. function f() { throw 500; diff --git a/paperproblems/exceptions/problem2.txt b/paperproblems/exceptions/problem2.txt index 1108a2c..d9f27c8 100644 --- a/paperproblems/exceptions/problem2.txt +++ b/paperproblems/exceptions/problem2.txt @@ -1,4 +1,4 @@ -What does the following print out? +What does the following print out? - g leads to h leads to f, throws 500 error which is caught by the function h try, console logs 500 throws its own error since functino h has also failed, function g the catches some error and console logs it giving 500 some error. function f() { throw 500; diff --git a/paperproblems/return/problem1.txt b/paperproblems/return/problem1.txt index fed99b8..980d58c 100644 --- a/paperproblems/return/problem1.txt +++ b/paperproblems/return/problem1.txt @@ -1,4 +1,4 @@ -What does this program output? +What does this program output? - 5 function f() { return 5; diff --git a/src/exceptions/problem1.js b/src/exceptions/problem1.js index f54c8f8..088b152 100644 --- a/src/exceptions/problem1.js +++ b/src/exceptions/problem1.js @@ -1,12 +1,31 @@ function first(arr) { // Throw an exception if the array has no elements // Otherwise return the first element + if (arr.length === 0) { + throw 500; + } else { + return arr[0] + } + } function detective(i) { + + try { + suspect(i); + } catch (err) { + var a = "something fishy"; + return a; + } + function suspect(i) { - if(i * 7 % 3 == 0) throw new Error("Bad i!"); + if (i * 7 % 3 == 0) throw new Error("Bad i!"); + + } + var b = "everything ok"; + return b; + // detective checks to see if the suspect throws an exception on input i. // Returns "everything ok" if the suspect doesn't. // Returns "something fishy" if the suspect does. @@ -17,6 +36,17 @@ function assignFlight(name) { var terrorSuspects = ["bob", "eric", "susie"]; // if the name is a terror suspect, throw an exception // Otherwise, return the flight number + var noFly = true; + for (var i = 0; i < terrorSuspects.length; i++) { + if (name === terrorSuspects[i]) { + throw new Error("terrorist"); + } else { + noFly = false; + } + } + + return flightNumber; } -module.exports = {first, detective, assignFlight} \ No newline at end of file + +module.exports = { first, detective, assignFlight }; \ No newline at end of file diff --git a/src/return/problem1.js b/src/return/problem1.js index c8f7b32..daacaa4 100644 --- a/src/return/problem1.js +++ b/src/return/problem1.js @@ -1,17 +1,9 @@ -// Remove as many characters from this function without changing its meaning. -// In other words, make this function as succinct as possible -// Also, remove these comments function f(x) { - if(x > 10) { + if (x > 10) { return "hello"; - } else if(x > 5) { + } else if (x > 5) { return "goodbye"; - } else { - return undefined; } } - -module.exports = f; // Don't delete this line but remove this comment. - - +module.exports = f; From 98427fedb83951e42db0b3741de7188648db267e Mon Sep 17 00:00:00 2001 From: Jody Smith Date: Mon, 15 Jan 2018 18:10:56 -0500 Subject: [PATCH 2/8] proto, bind, this, anon, hof and exceptions --- paperproblems/__proto__/problem2.txt | 8 +- paperproblems/__proto__/problem3.txt | 5 +- .../anonymous-functions/problem1.txt | 7 +- .../anonymous-functions/problem2.txt | 7 ++ .../anonymous-functions/problem3.txt | 6 ++ .../anonymous-functions/problem4.txt | 7 ++ .../anonymous-functions/problem5.txt | 10 +++ paperproblems/bind/problem1.txt | 8 +- paperproblems/bind/problem2.txt | 8 +- paperproblems/this/problem1.txt | 4 + paperproblems/this/problem2.txt | 4 + paperproblems/this/problem3.txt | 3 + src/HOF/problem1.js | 77 ++++++++++++++++--- src/__proto__/problem1.js | 2 + src/anonymous-functions/problem1.js | 3 +- src/bind/problem1.js | 3 + src/bind/problem2.js | 7 +- src/exceptions/problem1.js | 2 - src/testing.js | 7 ++ 19 files changed, 155 insertions(+), 23 deletions(-) create mode 100644 src/testing.js diff --git a/paperproblems/__proto__/problem2.txt b/paperproblems/__proto__/problem2.txt index 699ecd8..0549443 100644 --- a/paperproblems/__proto__/problem2.txt +++ b/paperproblems/__proto__/problem2.txt @@ -11,7 +11,7 @@ x4.__proto__ = x3; x1.age = 20; x3.age = 18; -console.log(x1.age); -console.log(x2.age); -console.log(x3.age); -console.log(x4.age); \ No newline at end of file +console.log(x1.age); 20 +console.log(x2.age); 20 +console.log(x3.age);18 +console.log(x4.age);18 \ No newline at end of file diff --git a/paperproblems/__proto__/problem3.txt b/paperproblems/__proto__/problem3.txt index aad4fcb..c730750 100644 --- a/paperproblems/__proto__/problem3.txt +++ b/paperproblems/__proto__/problem3.txt @@ -11,4 +11,7 @@ You get the following exception: a) Explain what this exception means. -b) Why does this exception exist? What's wrong with a cyclic __proto__ value? \ No newline at end of file +that there is a loop going from a to b to a to b... so an infinite search for answers. + +b) Why does this exception exist? What's wrong with a cyclic __proto__ value? +it will never return anything it will just keep looking. \ No newline at end of file diff --git a/paperproblems/anonymous-functions/problem1.txt b/paperproblems/anonymous-functions/problem1.txt index 08e09e7..ea3c549 100644 --- a/paperproblems/anonymous-functions/problem1.txt +++ b/paperproblems/anonymous-functions/problem1.txt @@ -5,4 +5,9 @@ function greet(x) { console.log("hello " + x); } -greet(bob); \ No newline at end of file + +var greet = function(x) { return console.log( "hello " + x); } + +greet(bob); + + diff --git a/paperproblems/anonymous-functions/problem2.txt b/paperproblems/anonymous-functions/problem2.txt index 7cfb344..1a1df3b 100644 --- a/paperproblems/anonymous-functions/problem2.txt +++ b/paperproblems/anonymous-functions/problem2.txt @@ -12,3 +12,10 @@ function call(f) { } call(greet); + +------- + +var greet = function(x) { console.log("hello " + x);} +var call = function(f) { f("bob"); } + +call(greet); \ No newline at end of file diff --git a/paperproblems/anonymous-functions/problem3.txt b/paperproblems/anonymous-functions/problem3.txt index 5d8a0fc..c13566b 100644 --- a/paperproblems/anonymous-functions/problem3.txt +++ b/paperproblems/anonymous-functions/problem3.txt @@ -10,3 +10,9 @@ function call(f) { } call(greet); + ---------------------- + +var greet = function (x, y) {console.log("hello " + x + " " + y); } +var call = function (f) { f("Bob", "Dole"); } + +call(greet); \ No newline at end of file diff --git a/paperproblems/anonymous-functions/problem4.txt b/paperproblems/anonymous-functions/problem4.txt index 689d724..36c9069 100644 --- a/paperproblems/anonymous-functions/problem4.txt +++ b/paperproblems/anonymous-functions/problem4.txt @@ -10,4 +10,11 @@ function twice(f) { f("mary"); } +twice(greet); + +------------------- + +var greet = function(x) {console.log("hello " + x);} +var twice = function(f) {f("bob"); f("mary");} + twice(greet); \ No newline at end of file diff --git a/paperproblems/anonymous-functions/problem5.txt b/paperproblems/anonymous-functions/problem5.txt index 2d69a4d..d63a844 100644 --- a/paperproblems/anonymous-functions/problem5.txt +++ b/paperproblems/anonymous-functions/problem5.txt @@ -15,5 +15,15 @@ function soften(f) { } var softAskOnADate = soften(askOnADate); + console.log(softAskOnADate("Eric")); console.log(softAskOnADate("Bob")); + +----------------------- +The answer is unnecessary rejection. + +Eric is a maybe Bob is I do. + + + + diff --git a/paperproblems/bind/problem1.txt b/paperproblems/bind/problem1.txt index e57fc23..2ecc98f 100644 --- a/paperproblems/bind/problem1.txt +++ b/paperproblems/bind/problem1.txt @@ -9,4 +9,10 @@ var obj = { obj.bar = obj.bar.bind({baz: 4}); -obj.bar(); \ No newline at end of file +obj.bar(); + +---------------- + +4 + +I got this right, but it wasn't exacty a confident call \ No newline at end of file diff --git a/paperproblems/bind/problem2.txt b/paperproblems/bind/problem2.txt index 6c9d16d..d3d7b01 100644 --- a/paperproblems/bind/problem2.txt +++ b/paperproblems/bind/problem2.txt @@ -15,4 +15,10 @@ eric.introduction = bob.introduction; eric.introduction = eric.introduction.bind({name: "Steve"}); -eric.introduction(); \ No newline at end of file +eric.introduction(); + + +----- +first guess was Steve, I was wrong. + +bob.intro is set to bob.intro.bind(bob), then eric is set to bob.intro so it gets bound then and the steve binding fails \ No newline at end of file diff --git a/paperproblems/this/problem1.txt b/paperproblems/this/problem1.txt index 7212ac6..268d69d 100644 --- a/paperproblems/this/problem1.txt +++ b/paperproblems/this/problem1.txt @@ -9,3 +9,7 @@ function foo() { var obj = {bar: foo, baz: 8}; obj.bar(); +---------------- + +would return 8, since obj is before the . so it's called from obj and baz has a value of 8. BUt only because foo is a function, so it runs it and prints baz. + diff --git a/paperproblems/this/problem2.txt b/paperproblems/this/problem2.txt index 1144503..4462ec0 100644 --- a/paperproblems/this/problem2.txt +++ b/paperproblems/this/problem2.txt @@ -10,3 +10,7 @@ var obj = { var g = obj.bar; g(); +------------- + +so this has no . before g, so is window context so hould return undefined window + diff --git a/paperproblems/this/problem3.txt b/paperproblems/this/problem3.txt index dcfda4d..8f13f86 100644 --- a/paperproblems/this/problem3.txt +++ b/paperproblems/this/problem3.txt @@ -15,3 +15,6 @@ var obj2 = { obj2.bar = obj.bar; obj2.bar(); +---------- + +wtf?... so obj2.bar = obj.bar makes both console.log(this.baz), then obj2.bar calls it's own baz which is 12? so basically the first part changes the functin being called, but since the function is called from obj2 it looks at it's own baz. diff --git a/src/HOF/problem1.js b/src/HOF/problem1.js index 0ed585e..8a95fb7 100644 --- a/src/HOF/problem1.js +++ b/src/HOF/problem1.js @@ -9,6 +9,16 @@ function callNoException(f, arg) { // } // callNoException(throwsZero, 0) returns null // callNoException(throwsZero, 12) returns 12 + try { + f(arg); + } catch (err) { + return null; + } + + function f(arg) { + if (arg == 0) throw new Error("dammit"); + } + return arg; } function callNoNull(f, arg) { @@ -21,8 +31,13 @@ function callNoNull(f, arg) { // } // callNoNull(nullZero, 0) throws an exception // callNoNull(nullZero, 12) returns 12 - - + + if (f(arg) == null) { + throw new Error("snafu"); + } else { + return arg; + } + } function exceptionalize(f) { @@ -39,9 +54,17 @@ function exceptionalize(f) { // exceptionalize(nullZero) returns a function g such that // g(0) throws an exception // g(12) returns 12 + function g(arg) { + if (arg == 0) throw new Error("snafu"); + return f(arg); + } + return g; } + + + function nullify(f) { // returns a new function // this function takes 1 input, called arg @@ -55,7 +78,20 @@ function nullify(f) { // nullify(throwsZero) returns a function g such that // g(0) returns null // g(12) throws an exception - + try { + g(); + } catch (err) { + return null; + } + + function g(f) { + if (f == 0) { + return null; + } else { + return f; + } + } + return g; } function map(lst, f) { @@ -69,6 +105,12 @@ function map(lst, f) { // // function toUpperCase(str) { return str.toUpperCase(); } // map(["bob", "susie"], toUpperCase) returns ["BOB", "SUSIE"] + + var returnLst = []; + for (var i = 0; i < lst.length; i++) { + returnLst.push(f(lst[i])); + } + return returnLst; } function filter(lst, f) { @@ -83,25 +125,42 @@ function filter(lst, f) { // Example: // function isEven(x) {return x % 2 == 0;} // filter([1, 2, 3, 4, 5], isEven) returns [2,4]; + var returnLst = []; + for (var i = 0; i < lst.length; i++) { + if (f(lst[i]) == true) { + returnLst.push(lst[i]); + } + } + return returnLst; } function every(lst, f) { // lst is an array and f is a function // f takes 1 arguments and returns a boolean // filter(lst, f) returns a true if f returns true for every element of lst - + // Example // every([2,4,12], x => x % 2 == 0) returns true - // every([2,3,12], x => x % 2 == 0) returns false + // every([2,3,12], x => x % 2 == 0) returns false + var returnLst = []; + for (var i = 0; i < lst.length; i++) { + if (f(lst[i]) == true) { + returnLst.push(lst[i]); + } else { + return false; + } + + } + return true; } module.exports = { - callNoException, + callNoException, callNoNull, - exceptionalize, + exceptionalize, nullify, - map, - filter, + map, + filter, every }; diff --git a/src/__proto__/problem1.js b/src/__proto__/problem1.js index 820a78d..2a3dbdd 100644 --- a/src/__proto__/problem1.js +++ b/src/__proto__/problem1.js @@ -3,4 +3,6 @@ var parent = {x: 5, y: 6, z: 8}; var child = {x : 10}; +child.__proto__ = parent; + module.exports = {parent, child} \ No newline at end of file diff --git a/src/anonymous-functions/problem1.js b/src/anonymous-functions/problem1.js index ab1384c..e70a080 100644 --- a/src/anonymous-functions/problem1.js +++ b/src/anonymous-functions/problem1.js @@ -1,4 +1,5 @@ // fix all the errors + function c(g, h) { var x = g(6); var y = h(8); @@ -6,7 +7,7 @@ function c(g, h) { } function t() { - return c(function g(x) {return y + 1}, function h(y) {return x * 2}); + return c((function g(x) {return x + 1}), (function h(y) {return y * 2})); } module.exports = t; \ No newline at end of file diff --git a/src/bind/problem1.js b/src/bind/problem1.js index da0b2d6..3c166e2 100644 --- a/src/bind/problem1.js +++ b/src/bind/problem1.js @@ -4,4 +4,7 @@ function greet() { } // bind greet to bob +var greet = greet.bind(bob); + + module.exports = greet; \ No newline at end of file diff --git a/src/bind/problem2.js b/src/bind/problem2.js index 079a343..a90c5c8 100644 --- a/src/bind/problem2.js +++ b/src/bind/problem2.js @@ -1,9 +1,10 @@ // Fix all the errors in this program var dog = {breed: "schnitzel"}; function greet() { - return "I'm a " + this.bred; + return "I'm a " + this.breed; } -greet.bind(dog); +var greet = greet.bind(dog); -module.exports = greet; \ No newline at end of file +module.exports = greet; +console.log(greet); \ No newline at end of file diff --git a/src/exceptions/problem1.js b/src/exceptions/problem1.js index 088b152..e48b152 100644 --- a/src/exceptions/problem1.js +++ b/src/exceptions/problem1.js @@ -20,8 +20,6 @@ function detective(i) { function suspect(i) { if (i * 7 % 3 == 0) throw new Error("Bad i!"); - - } var b = "everything ok"; return b; diff --git a/src/testing.js b/src/testing.js new file mode 100644 index 0000000..1e02e98 --- /dev/null +++ b/src/testing.js @@ -0,0 +1,7 @@ + +function f() { + return 5; + return "hello"; +} + +console.log(f()); \ No newline at end of file From 3694733a93f3c6b603d51f9bffab311247fb20ae Mon Sep 17 00:00:00 2001 From: Jody Smith Date: Mon, 15 Jan 2018 19:24:31 -0500 Subject: [PATCH 3/8] update to anon functions paper probs --- paperproblems/anonymous-functions/problem1.txt | 1 + paperproblems/anonymous-functions/problem2.txt | 4 +++- paperproblems/anonymous-functions/problem3.txt | 4 +++- paperproblems/anonymous-functions/problem4.txt | 5 ++++- paperproblems/this/problem4.txt | 8 +++++++- src/this/problem1.js | 5 +++++ 6 files changed, 23 insertions(+), 4 deletions(-) diff --git a/paperproblems/anonymous-functions/problem1.txt b/paperproblems/anonymous-functions/problem1.txt index ea3c549..755fe0a 100644 --- a/paperproblems/anonymous-functions/problem1.txt +++ b/paperproblems/anonymous-functions/problem1.txt @@ -8,6 +8,7 @@ function greet(x) { var greet = function(x) { return console.log( "hello " + x); } +(function(x) {return console.log("Hello " + x);}("bob") greet(bob); diff --git a/paperproblems/anonymous-functions/problem2.txt b/paperproblems/anonymous-functions/problem2.txt index 1a1df3b..a4192b3 100644 --- a/paperproblems/anonymous-functions/problem2.txt +++ b/paperproblems/anonymous-functions/problem2.txt @@ -18,4 +18,6 @@ call(greet); var greet = function(x) { console.log("hello " + x);} var call = function(f) { f("bob"); } -call(greet); \ No newline at end of file +call(greet); +--------------- then just throw the var contents into () and call it completely anonymously. +(function(f) { f ("bob") ; } )(function(x) {console.log("Hello " + x);}) \ No newline at end of file diff --git a/paperproblems/anonymous-functions/problem3.txt b/paperproblems/anonymous-functions/problem3.txt index c13566b..7068aff 100644 --- a/paperproblems/anonymous-functions/problem3.txt +++ b/paperproblems/anonymous-functions/problem3.txt @@ -15,4 +15,6 @@ call(greet); var greet = function (x, y) {console.log("hello " + x + " " + y); } var call = function (f) { f("Bob", "Dole"); } -call(greet); \ No newline at end of file +call(greet); + +(function(f) { f("bob", "dole");})(funciton(x,y) {console.log("hello " + x + " " + y);}) \ No newline at end of file diff --git a/paperproblems/anonymous-functions/problem4.txt b/paperproblems/anonymous-functions/problem4.txt index 36c9069..5434a6d 100644 --- a/paperproblems/anonymous-functions/problem4.txt +++ b/paperproblems/anonymous-functions/problem4.txt @@ -17,4 +17,7 @@ twice(greet); var greet = function(x) {console.log("hello " + x);} var twice = function(f) {f("bob"); f("mary");} -twice(greet); \ No newline at end of file +twice(greet); + +---------------------- +(function(f) {f("bob"); f("mary");})(function(x) {console.log("hello " + x);}) \ No newline at end of file diff --git a/paperproblems/this/problem4.txt b/paperproblems/this/problem4.txt index d7a9ebd..59131b8 100644 --- a/paperproblems/this/problem4.txt +++ b/paperproblems/this/problem4.txt @@ -11,4 +11,10 @@ function f(g) { console.log(g(4)); } -f(obj.bar); \ No newline at end of file +f(obj.bar); + +----------- + +pass obj.bar into f, which tells us to console.log obj.bar(4), which tells us to function (4) (console.log(this.baz + 4), 12+4 is 16, so hopefully this gives me 16... + +which of fucking course it doesn't.... which is because it is called from function(i)... which has no . in front of it so the rule says window/error :( \ No newline at end of file diff --git a/src/this/problem1.js b/src/this/problem1.js index b7b2740..4806ea7 100644 --- a/src/this/problem1.js +++ b/src/this/problem1.js @@ -1,6 +1,11 @@ 'use strict'; function whatsMyAgeAgain() { // returns this.age unless this is not defined. If this is not defined, return 18 + if (this === undefined) { + return 18; + } else { + return this.age + } } module.exports = whatsMyAgeAgain; \ No newline at end of file From cd7b1e89cb5c1428fcace31a9ac30206232f6f53 Mon Sep 17 00:00:00 2001 From: Jody Smith Date: Tue, 16 Jan 2018 20:19:48 -0500 Subject: [PATCH 4/8] arrow functions, variable scope and constructor-functions --- .../constructor-functions/problem2.txt | 6 +++- .../constructor-functions/problem3.txt | 14 +++++++- .../constructor-functions/problem4.txt | 6 +++- .../constructor-functions/problem5.txt | 8 ++++- paperproblems/variable-scoping/problem1.txt | 4 +++ paperproblems/variable-scoping/problem2.txt | 5 ++- paperproblems/variable-scoping/problem3.txt | 8 ++++- paperproblems/variable-scoping/problem4.txt | 4 ++- src/arrow-functions/problem1.js | 34 ++++++++++++++----- src/arrow-functions/problem2.js | 18 ++++++++-- src/bind/problem1.js | 1 + src/constructor-functions/problem1.js | 18 ++++++++++ src/variable-scoping/problem1.js | 4 +-- 13 files changed, 109 insertions(+), 21 deletions(-) diff --git a/paperproblems/constructor-functions/problem2.txt b/paperproblems/constructor-functions/problem2.txt index 4cb7dd9..d18b498 100644 --- a/paperproblems/constructor-functions/problem2.txt +++ b/paperproblems/constructor-functions/problem2.txt @@ -12,4 +12,8 @@ var bob = new Person("Bob", 30); Person.prototype.leave = function() {return this.name + " is leaving";} -bob.leave(); \ No newline at end of file +bob.leave(); + +----------------- + +Bob is leaving \ No newline at end of file diff --git a/paperproblems/constructor-functions/problem3.txt b/paperproblems/constructor-functions/problem3.txt index 2c875ee..9635400 100644 --- a/paperproblems/constructor-functions/problem3.txt +++ b/paperproblems/constructor-functions/problem3.txt @@ -11,9 +11,21 @@ function Person(name, age) { var bob = new Person("Bob", 30); bob.constructor.prototype.salary = 40000; + bob.__proto__.salary = bob.__proto__.salary + 100; Person.prototype.salary = Person.prototype.salary + 300; Person.__proto__.salary = Person.__proto__.salary + 400; bob.salary = bob.salary + 50; -console.log(bob.salary); \ No newline at end of file +console.log(bob.salary); + +----------------- + +40000 + 100 + 300 + 400 + 50 +40850 - since all of the calls are adding money to the same value.... right?.... wrong.... + +damn it... Person.__proto__.salary is not a thing. bob can have a proto, Person can have a prototype, so 40450 is the answer \ No newline at end of file diff --git a/paperproblems/constructor-functions/problem4.txt b/paperproblems/constructor-functions/problem4.txt index 10d57df..410bfd3 100644 --- a/paperproblems/constructor-functions/problem4.txt +++ b/paperproblems/constructor-functions/problem4.txt @@ -12,4 +12,8 @@ var bob = Person("Bob", 30); bob.name = bob.name + " Dole"; -bob.greet(); \ No newline at end of file +bob.greet(); + +---------------- + +Well I'd guess..."Hello my name is Bob Dole", but that of course would be wrong because the console.log is being called from the function() which has no damn context. \ No newline at end of file diff --git a/paperproblems/constructor-functions/problem5.txt b/paperproblems/constructor-functions/problem5.txt index f47e2b8..4b666f1 100644 --- a/paperproblems/constructor-functions/problem5.txt +++ b/paperproblems/constructor-functions/problem5.txt @@ -9,4 +9,10 @@ function Person(name, age) { } } -var bob = Person("Bob", 30); \ No newline at end of file +var bob = new Person("Bob", 30); + +-------------------- + +var bob = Person("Bob", 30); + +var Person = bob.bind(bob) \ No newline at end of file diff --git a/paperproblems/variable-scoping/problem1.txt b/paperproblems/variable-scoping/problem1.txt index 281bdd6..2646c96 100644 --- a/paperproblems/variable-scoping/problem1.txt +++ b/paperproblems/variable-scoping/problem1.txt @@ -9,3 +9,7 @@ function f() { f(); f(); + +--------------------- +2 +4 \ No newline at end of file diff --git a/paperproblems/variable-scoping/problem2.txt b/paperproblems/variable-scoping/problem2.txt index eb70c9d..60b91f8 100644 --- a/paperproblems/variable-scoping/problem2.txt +++ b/paperproblems/variable-scoping/problem2.txt @@ -7,4 +7,7 @@ function f() { } f(); -f(); \ No newline at end of file +f(); +---------------- +2 +2 \ No newline at end of file diff --git a/paperproblems/variable-scoping/problem3.txt b/paperproblems/variable-scoping/problem3.txt index ba8ada5..3364b26 100644 --- a/paperproblems/variable-scoping/problem3.txt +++ b/paperproblems/variable-scoping/problem3.txt @@ -11,4 +11,10 @@ function f() { f(); f(); -console.log(y); \ No newline at end of file +console.log(y); + +--------------- + +7 +9 +3 \ No newline at end of file diff --git a/paperproblems/variable-scoping/problem4.txt b/paperproblems/variable-scoping/problem4.txt index 2294b2e..bbb9744 100644 --- a/paperproblems/variable-scoping/problem4.txt +++ b/paperproblems/variable-scoping/problem4.txt @@ -14,4 +14,6 @@ function f() { } } -} \ No newline at end of file +} + +p, h, z, g, y, f, x \ No newline at end of file diff --git a/src/arrow-functions/problem1.js b/src/arrow-functions/problem1.js index 5c0873a..c13e64f 100644 --- a/src/arrow-functions/problem1.js +++ b/src/arrow-functions/problem1.js @@ -1,14 +1,30 @@ +// arrow function rules. either () => { ... } or () => ... or OnlyOnPara => {...}. The bit to the left of the arrow is the parameters and if there's only one we don't +// need braces, otherwise we do. to the right of the arror we don't need curly braces if it's just a expression (evals to a value) but do need the curlies if it's +// a statement (multi lines to evaluate) + + // fix all the errors. -function c(g, h) { - var x = g(6); - var y = h(8, 10); - return [x, y]; -} +// function c(g, h) { +// var x = g(6); +// var y = h(8, 10); +// return [x, y]; +// } -function t() { - return c( x => return y + 2, (x,y) => return x + y); -} +// function t() { +// return c( x => return y + 2, (x,y) => return x + y); +// } -module.exports = t +// module.exports = t +function c(g, h) { + var x = g(6); + var y = h(8, 10); + return [x, y]; + } + + function t() { + return c( x => {return x + 2}, (x,y) => {return x + y}); + } + + module.exports = t \ No newline at end of file diff --git a/src/arrow-functions/problem2.js b/src/arrow-functions/problem2.js index 1ae3fdb..79dbe4e 100644 --- a/src/arrow-functions/problem2.js +++ b/src/arrow-functions/problem2.js @@ -1,9 +1,21 @@ // Convert all the arrow functions to normal anonymous functions // There should be no arrows by the end -var x = x => x + 1; -var y = (x, y) => x + y; -var z = x => {var y = (x * 7) % 2; return y * 2}; + +var x = function (x) { + return x + 1; + +} + +var y = function (x, y) { + return x + y; + +} + +var z = function (x) { + var y = (x * 7) % 2; + return y * 2; +} module.exports = {x, y, z}; diff --git a/src/bind/problem1.js b/src/bind/problem1.js index 3c166e2..f1c1d4b 100644 --- a/src/bind/problem1.js +++ b/src/bind/problem1.js @@ -7,4 +7,5 @@ function greet() { var greet = greet.bind(bob); + module.exports = greet; \ No newline at end of file diff --git a/src/constructor-functions/problem1.js b/src/constructor-functions/problem1.js index b39887c..24ecbd4 100644 --- a/src/constructor-functions/problem1.js +++ b/src/constructor-functions/problem1.js @@ -1,2 +1,20 @@ // Add a function to all arrays called isNotEmpty // isNotEmpty returns true is the array is empty, false otherwise + +// since it has to be on all arrays it needs to be in the prorotype. Then since I will want it to be based on the Array being passe din I have to use "this.length" I had look at slide 352 to understand, which had -- +// var x = new Array(); +// var y = [1]; +// Array.prototype.isEmpty = function() { return this.length == 0; } +// console.log(x.isEmpty()); + + +Array.prototype.isNotEmpty = function () { + //console.log(this.length); + if (this.length == 0) { + return false; + } else { + + //console.log("I always run this"); + return true; + } +} \ No newline at end of file diff --git a/src/variable-scoping/problem1.js b/src/variable-scoping/problem1.js index da8f429..993742c 100644 --- a/src/variable-scoping/problem1.js +++ b/src/variable-scoping/problem1.js @@ -2,9 +2,9 @@ // It should return a different number every time it is called // The first time it is called it returns 1 // Every call thereafter returns a number one greater than the last - +var x = 0; function f() { - var x = 0; + x = x + 1; return x; } From b24debac6efab09a35ca6aa2f7b14c230ec663e1 Mon Sep 17 00:00:00 2001 From: Jody Smith Date: Wed, 17 Jan 2018 16:29:02 -0500 Subject: [PATCH 5/8] Callbacks, Inheritence and Classes. --- paperproblems/arrow-functions/problem1.txt | 14 ++++++------ paperproblems/callbacks/problem1.txt | 11 +++++++++- paperproblems/callbacks/problem2.txt | 10 ++++++++- .../constructor-functions/problem5.txt | 8 +++++-- paperproblems/inheritance/problem1.txt | 8 ++++++- paperproblems/inheritance/problem2.txt | 17 ++++++++++++++ src/callbacks/problem1.js | 12 +++++++--- src/classes/problem1.js | 10 ++++++++- src/inheritance/problem1.js | 22 +++++++++++++++++-- src/inheritance/problem2.js | 10 ++++----- 10 files changed, 99 insertions(+), 23 deletions(-) diff --git a/paperproblems/arrow-functions/problem1.txt b/paperproblems/arrow-functions/problem1.txt index 7338e61..3fc5348 100644 --- a/paperproblems/arrow-functions/problem1.txt +++ b/paperproblems/arrow-functions/problem1.txt @@ -2,18 +2,18 @@ For each of the following expressions: - Does it have a syntax error? - If it doesn't have a syntax error, what are the probable input and output types of the function? -a) x => x + 1 +a) x => x + 1 // good - x would be a number in and out -b) x, y => x * y +b) x, y => x * y // bad 2 params so (x, y) => x* y, again number in and out for types given the * -c) x => { x * 2 } +c) x => { x * 2 } // seems fine, number in and out, don't need the {} though, could be x => x *2 -d) (x, z) => {console.log(z); return x * z} +d) (x, z) => {console.log(z); return x * z} // no problem, I would assume input and out put of numbers since console log z could be a string but the x * z would throw an error since you can't multiple strings. -e) x => console.log(z); return x * z +e) x => console.log(z); return x * z // function needs {} since it's a statement, so x => {console.log(z); return x * z;} - gonna assume numbers again becase fo the * -f) (x) => x * 2 +f) (x) => x * 2 // don't need the () since only one param. x => x * 2 , number types again -e) () => console.log("hello") +e) () => console.log("hello") // anonymous nothing in and nothing returned (so implicit undefined) When you're done, check all your answers in the developer console. \ No newline at end of file diff --git a/paperproblems/callbacks/problem1.txt b/paperproblems/callbacks/problem1.txt index 63df256..e94a454 100644 --- a/paperproblems/callbacks/problem1.txt +++ b/paperproblems/callbacks/problem1.txt @@ -12,4 +12,13 @@ function h() { setTimeout(f, 1000); } -setTimeout(h, 200); \ No newline at end of file +setTimeout(h, 200); + + +----------------------- +wtf :) callback inception +first guess: +setTimeout Calls h, which calls setTimeout which calls f which calls set Timeout, which calls g which console logs "hello" (right away) returns undefined in a cascading flow of failure all the way back to the start +next guess after running it: +...and realising that h was not h() so passed the funciton and not the result meaning that h waits 200 ms before f waits 1000 ms before g waits 500 ms before printing "Hello!" + diff --git a/paperproblems/callbacks/problem2.txt b/paperproblems/callbacks/problem2.txt index 1ee06dd..0cdd835 100644 --- a/paperproblems/callbacks/problem2.txt +++ b/paperproblems/callbacks/problem2.txt @@ -8,4 +8,12 @@ function h() { setInterval(g, 1000); } -setInterval(h, 1000); \ No newline at end of file +setInterval(h, 1000); + +-------------- +before running it: +repeatedly print hello every 2 seconds? + +after running it: +realising that h will repeat every second and call g to ALSO repeat every second which +it will continuously spawn more interval loops. So by the 60th second we will have ~ 60 intervals looping around printing hello. that was fun. diff --git a/paperproblems/constructor-functions/problem5.txt b/paperproblems/constructor-functions/problem5.txt index 4b666f1..0a12583 100644 --- a/paperproblems/constructor-functions/problem5.txt +++ b/paperproblems/constructor-functions/problem5.txt @@ -13,6 +13,10 @@ var bob = new Person("Bob", 30); -------------------- -var bob = Person("Bob", 30); +function Person(name, age) { + this.name = name; + this.age = age; + this.greet = () => {console.log("Hello my name is " + this.name);} +} -var Person = bob.bind(bob) \ No newline at end of file +var bob = new Person("Bob", 30); \ No newline at end of file diff --git a/paperproblems/inheritance/problem1.txt b/paperproblems/inheritance/problem1.txt index 3de989f..a4c2e88 100644 --- a/paperproblems/inheritance/problem1.txt +++ b/paperproblems/inheritance/problem1.txt @@ -24,4 +24,10 @@ class Square extends Shape { } var s = new Square(5); -console.log(s.toString()); \ No newline at end of file +console.log(s.toString()); + + + +------------- + +square with area 25 and perimeter 20 \ No newline at end of file diff --git a/paperproblems/inheritance/problem2.txt b/paperproblems/inheritance/problem2.txt index f9d6898..63e6c16 100644 --- a/paperproblems/inheritance/problem2.txt +++ b/paperproblems/inheritance/problem2.txt @@ -11,3 +11,20 @@ class Shape { this.area() + " and perimeter " + this.perimeter(); } } + +class Rectangle extends Shape { + constructor (x, y) { + super("Rectangle"); + this.length = x; + this.width = y; + } + area() { + return this.width * this.length; + } + perimeter () { + return this.width * 2 + this.length * 2 + } +} + +var r = new Rectangle(10,5); +console.log(r.toString()); diff --git a/src/callbacks/problem1.js b/src/callbacks/problem1.js index 0e8eb76..66c0c21 100644 --- a/src/callbacks/problem1.js +++ b/src/callbacks/problem1.js @@ -1,7 +1,13 @@ // Fix all the errors. It should print hello after 1 second -function shout(x) { - console.log(x.toUppercase()); +// function shout(x) { +// console.log(x.toUppercase()); +// } + +// SetTimeout(shout("hello"), 1); + +function shout() { + console.log("hello"); } -SetTimeout(shout("hello"), 1); \ No newline at end of file +setTimeout(shout, 1000); \ No newline at end of file diff --git a/src/classes/problem1.js b/src/classes/problem1.js index 8e1bcc9..7889014 100644 --- a/src/classes/problem1.js +++ b/src/classes/problem1.js @@ -1,7 +1,15 @@ class Dog { + constructor (age, name, breed) { + this.age = age; + this.name = name; + this.breed = breed; + } + bark() { + return "bark"; + } // Dog has a constructor with three arguments (in this order): age, name and breed // Dog has three attributes: age, name and breed // Dog has a method bark, which returns a string } -module.exports = Dog; \ No newline at end of file +module.exports = Dog \ No newline at end of file diff --git a/src/inheritance/problem1.js b/src/inheritance/problem1.js index 71e66b5..046f9df 100644 --- a/src/inheritance/problem1.js +++ b/src/inheritance/problem1.js @@ -4,8 +4,20 @@ class Shape { } } -class Rectangle { +class Rectangle extends Shape{ + constructor (x, y) { + super(); + this.width = x; + this.length = y; + } + + area() { + return this.width * this.length; + } + perimeter() { + return this.width * 2 + this.length * 2; + } // A rectangle is a shape // Every rectangle has a width and a height // Implement the constructor @@ -13,7 +25,13 @@ class Rectangle { // The constructor has two arguments: width and height } -class Square { +class Square extends Rectangle{ + constructor (x) { + super(); + this.length = x; + this.width = x; + } + // A square is a rectangle // Every square has a width and a height // The height and width of a square are always the same diff --git a/src/inheritance/problem2.js b/src/inheritance/problem2.js index f74dc6b..e5d9f98 100644 --- a/src/inheritance/problem2.js +++ b/src/inheritance/problem2.js @@ -2,21 +2,21 @@ class Shape { constructor(shapeName) { - this.shapName = shapeName; + this.shapeName = shapeName; } toString() { return this.shapeName + " with area " + - this.area() + " and perimeter " + this.permeter(); + this.area() + " and perimeter " + this.perimeter(); } } -class Square { +class Square extends Shape { constructor(size) { - supr("square"); + super("square"); this.size = size; } area() { - return this.size * this.siz; + return this.size * this.size; } perimeter() { return this.size * 4; From 7a60d6974cae0fda6ea80c6eb86735d61daa626a Mon Sep 17 00:00:00 2001 From: Jody Smith Date: Thu, 18 Jan 2018 16:57:28 -0500 Subject: [PATCH 6/8] array functions and conditional operator --- paperproblems/array-functions/problem1.txt | 8 +++++- paperproblems/array-functions/problem2.txt | 10 ++++++- paperproblems/array-functions/problem3.txt | 13 ++++++++- paperproblems/array-functions/problem4.txt | 8 ++++++ .../conditional-operator/problem1.txt | 7 ++++- src/array-functions/problem1.js | 28 +++++++++++++++++-- src/conditional-operator/problem1.js | 26 ++++++----------- src/conditional-operator/problem2.js | 19 +++++++++---- 8 files changed, 89 insertions(+), 30 deletions(-) diff --git a/paperproblems/array-functions/problem1.txt b/paperproblems/array-functions/problem1.txt index 8e97911..c651e00 100644 --- a/paperproblems/array-functions/problem1.txt +++ b/paperproblems/array-functions/problem1.txt @@ -13,4 +13,10 @@ var dogs = animals.filter( function(animal) {return animal.species === 'dog';}); -console.log(dogs.length); \ No newline at end of file +console.log(dogs.length); + +---------------------------- + +whoa... + +ok so, using an anonymous function to filter based on animal species being dog, and adding to the dogs var (seeing as filter is an array function I guess it figures out it's an array). there are two objects within animals array that have dog s a species, so I guess it would return 2 \ No newline at end of file diff --git a/paperproblems/array-functions/problem2.txt b/paperproblems/array-functions/problem2.txt index e9050e5..d061882 100644 --- a/paperproblems/array-functions/problem2.txt +++ b/paperproblems/array-functions/problem2.txt @@ -13,4 +13,12 @@ var letterN = animals.filter(function(animal) { return animal.name !== undefined && animal.name[0] === 'N' }); -console.log(letterN[0].name); \ No newline at end of file +console.log(letterN[0].name); + + +---------------------------- + +another anon function, which if i understand it right, if the animal name is not undefined, and the first letter is N, then add it to the array. so Nacho and Neckbeard. +now... the console log... wtf is going on... array0 the first name which id assume would be nacho cause of execution order.. so + +Nacho diff --git a/paperproblems/array-functions/problem3.txt b/paperproblems/array-functions/problem3.txt index e1182ab..c15f845 100644 --- a/paperproblems/array-functions/problem3.txt +++ b/paperproblems/array-functions/problem3.txt @@ -10,4 +10,15 @@ var animals = [ var animalNames = animals.map( function(animal) {return animal.name}); -console.log(animalNames.join()); \ No newline at end of file +console.log(animalNames.join()); + + +--------------------- + +anon function to make a new array called animal Names. it returns animal.name, so id have an array with the 5/6 names.then the console log joins them. so.. + +NachoRamsesFlufftailPopcornNeckbeard + +which coincidentally sounds like a repl file name. + +nope... it still has the , inbetween each name. so join() does not join them all as a string, but rather takes each individual array index and puts it into one. \ No newline at end of file diff --git a/paperproblems/array-functions/problem4.txt b/paperproblems/array-functions/problem4.txt index 8b933aa..6701078 100644 --- a/paperproblems/array-functions/problem4.txt +++ b/paperproblems/array-functions/problem4.txt @@ -15,4 +15,12 @@ animals.some(isDog) animals.every(isDog) +------------------ + +well we didn't cover some or every in class so as a complete guess.. (nah.. googled it). SO some is if anything in the array returns true, every requires everythign in the array +to return tre for it to be true ( so kinda like an or/and). So there's nothing in the program to print anythign so I wouldn't get much, but some would return true and every would +return false. + +This would be very useful for the compare arrays for uniques problem :) + diff --git a/paperproblems/conditional-operator/problem1.txt b/paperproblems/conditional-operator/problem1.txt index fabd9e8..9cf8ebf 100644 --- a/paperproblems/conditional-operator/problem1.txt +++ b/paperproblems/conditional-operator/problem1.txt @@ -4,4 +4,9 @@ function f(x) { return x < 5 ? 3 : x > 8 ? 4 : x == 6 ? 12 : 9; } -console.log(f(5)); \ No newline at end of file +console.log(f(5)); + + +-------------------- + +soooo... x is 5, so if x is smaller than 5 (it's not) so onto the false, is x > 8, it's not, so onto the false, is x ==6, nope. so we console log 9. \ No newline at end of file diff --git a/src/array-functions/problem1.js b/src/array-functions/problem1.js index 06bc426..58e59de 100644 --- a/src/array-functions/problem1.js +++ b/src/array-functions/problem1.js @@ -1,17 +1,31 @@ function removeEvens(lst) { + var result = []; + for (var i = 1; i < lst.length; i++) { + if (lst[i] % 2 != 0) { + //console.log(lst[i]); + result.push(lst[i]); + //console.log("this is " + result); + } + } + return result; // lst is an array of numbers // Returns a new list with all the even numbers of lst removed } function keepLong(lst) { - // lst is an array of strings - // Returns a new list with all the elements of lst that are length greater than 5 + // console.log(lst); + var longLst = lst.filter( x => x.length > 5); + // console.log(longLst); + return longLst; } function greet(lst) { // lst is an array of strings + // console.log(lst); // Adds "Hello " to every element of greet // For example: greet(["bob", "eric"]) returns ["Hello bob", "Hello eric"] + var hola = lst.map((x) => { var y = "Hello " + x; return y }) + return hola; } function greetLong(lst) { @@ -19,11 +33,21 @@ function greetLong(lst) { // Only greet people who's names have length at least 4. // Otherwise ignore them completely. // For example: greeLong(["bob", "daniel"]) returns ["Hello daniel"] + // filter then greet + + var filteredLst = lst.filter(x => x.length > 4); + var result = filteredLst.map(x => { var y = "Hello " + x; return y}); + return result; } function allLong(lst) { // lst is an array of strings // Returns true if every element of lst is of length at least 5. Otherwise returns false. + // some every quesiton I think + // console.log (lst); + var a = lst.every((x) => {return x.length >= 5} ); + // console.log(a); + return a; } module.exports = {removeEvens, keepLong, greet, greetLong, allLong}; \ No newline at end of file diff --git a/src/conditional-operator/problem1.js b/src/conditional-operator/problem1.js index af6e31d..e2aabf1 100644 --- a/src/conditional-operator/problem1.js +++ b/src/conditional-operator/problem1.js @@ -1,23 +1,13 @@ -//Remove the if statements from these functions. -//Replace them with the conditional operator -function desirability(x) { - if(x == 'Brad Pitt') { - return "very desirable"; - } else { - return "not so desirable"; - } -} +var results = [ + "very desirable", + "also desirable", + "not desirable", + "not so desirable" +]; -function broadenHorizon(x) { - if(x == 'Brad Pitt') { - return "very desirable"; - } else if(x == 'Angelina Jolie') { - return "also desirable"; - } else { - return "not desirable"; - } -} +var desirability = (x) => x === "Brad Pitt" ? results[0] : results[3] +var broadenHorizon = (x) => x === "Brad Pitt" ? results[0] : x === "Angelina Jolie" ? results[1] : results[2] module.exports = {desirability, broadenHorizon} \ No newline at end of file diff --git a/src/conditional-operator/problem2.js b/src/conditional-operator/problem2.js index 2dd85bf..cb5ba15 100644 --- a/src/conditional-operator/problem2.js +++ b/src/conditional-operator/problem2.js @@ -1,12 +1,19 @@ -// Remove the conditional operator from these functions -// Replace them with if statements - function iLike(x) { - return x == 'chinese food' ? true : false; + if (x == 'chinese food') { + return true; + } else { + return false; + } } function iLikeLessPicky(x) { - return x == 'chinese food' ? true : x == 'french food' ? true : false; + if (x == 'chinese food') { + return true; + } else if (x == 'french food') { + return true; + } else { + return false; + } } -module.exports = {iLike, iLikeLessPicky}; \ No newline at end of file +module.exports = { iLike, iLikeLessPicky }; \ No newline at end of file From ba25f36f019dab217a1f264f4cf6e3d09788b28a Mon Sep 17 00:00:00 2001 From: Jody Smith Date: Thu, 18 Jan 2018 17:04:23 -0500 Subject: [PATCH 7/8] adding file --- paperproblems/expansion/problem1.txt | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/paperproblems/expansion/problem1.txt b/paperproblems/expansion/problem1.txt index 0f38755..e7fbb44 100644 --- a/paperproblems/expansion/problem1.txt +++ b/paperproblems/expansion/problem1.txt @@ -1,11 +1,11 @@ -// Expand each of the following -// #1 -console.log(({foo: 6}).foo + [1,2,3].length) -// #2 -(new Array()).concat(5).concat(3).length -// #3 -while([].filter(y => y > 1).length > 3) {} -// #4 -[].concat((() => 4)()) -// #5 -({foo: [4]}).foo[0] + [5,6,10][2] \ No newline at end of file ++// Expand each of the following ++// #1 ++console.log(({foo: 6}).foo + [1,2,3].length) ++// #2 ++(new Array()).concat(5).concat(3).length ++// #3 ++while([].filter(y => y > 1).length > 3) {} ++// #4 ++[].concat((() => 4)()) ++// #5 ++({foo: [4]}).foo[0] + [5,6,10][2] \ No newline at end of file From 06c1ea37c75214469c076fd3733a15dd3f08de76 Mon Sep 17 00:00:00 2001 From: Jody Smith Date: Thu, 18 Jan 2018 17:06:09 -0500 Subject: [PATCH 8/8] what is package-lock anyway --- package-lock.json | 326 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 326 insertions(+) create mode 100644 package-lock.json diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..f09c238 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,326 @@ +{ + "name": "javascript-fundamentals", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "assertion-error": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", + "dev": true + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true + }, + "brace-expansion": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz", + "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=", + "dev": true, + "requires": { + "balanced-match": "1.0.0", + "concat-map": "0.0.1" + } + }, + "browser-stdout": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.0.tgz", + "integrity": "sha1-81HTKWnTL6XXpVZxVCY9korjvR8=", + "dev": true + }, + "chai": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-3.5.0.tgz", + "integrity": "sha1-TQJjewZ/6Vi9v906QOxW/vc3Mkc=", + "dev": true, + "requires": { + "assertion-error": "1.1.0", + "deep-eql": "0.1.3", + "type-detect": "1.0.0" + } + }, + "chai-spies": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/chai-spies/-/chai-spies-0.7.1.tgz", + "integrity": "sha1-ND2Z9RJEIS6LF+ZLk5lv97LCqbE=", + "dev": true + }, + "commander": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.9.0.tgz", + "integrity": "sha1-nJkJQXbhIkDLItbFFGCYQA/g99Q=", + "dev": true, + "requires": { + "graceful-readlink": "1.0.1" + } + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "debug": { + "version": "2.6.8", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.8.tgz", + "integrity": "sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw=", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "deep-eql": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-0.1.3.tgz", + "integrity": "sha1-71WKyrjeJSBs1xOQbXTlaTDrafI=", + "dev": true, + "requires": { + "type-detect": "0.1.1" + }, + "dependencies": { + "type-detect": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-0.1.1.tgz", + "integrity": "sha1-C6XsKohWQORw6k6FBZcZANrFiCI=", + "dev": true + } + } + }, + "diff": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.2.0.tgz", + "integrity": "sha1-yc45Okt8vQsFinJck98pkCeGj/k=", + "dev": true + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "glob": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.1.tgz", + "integrity": "sha1-gFIR3wT6rxxjo2ADBs31reULLsg=", + "dev": true, + "requires": { + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" + } + }, + "graceful-readlink": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz", + "integrity": "sha1-TK+tdrxi8C+gObL5Tpo906ORpyU=", + "dev": true + }, + "growl": { + "version": "1.9.2", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.9.2.tgz", + "integrity": "sha1-Dqd0NxXbjY3ixe3hd14bRayFwC8=", + "dev": true + }, + "has-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz", + "integrity": "sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo=", + "dev": true + }, + "he": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", + "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", + "dev": true + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "requires": { + "once": "1.4.0", + "wrappy": "1.0.2" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "dev": true + }, + "json3": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/json3/-/json3-3.3.2.tgz", + "integrity": "sha1-PAQ0dD35Pi9cQq7nsZvLSDV19OE=", + "dev": true + }, + "lodash._baseassign": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz", + "integrity": "sha1-jDigmVAPIVrQnlnxci/QxSv+Ck4=", + "dev": true, + "requires": { + "lodash._basecopy": "3.0.1", + "lodash.keys": "3.1.2" + } + }, + "lodash._basecopy": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz", + "integrity": "sha1-jaDmqHbPNEwK2KVIghEd08XHyjY=", + "dev": true + }, + "lodash._basecreate": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash._basecreate/-/lodash._basecreate-3.0.3.tgz", + "integrity": "sha1-G8ZhYU2qf8MRt9A78WgGoCE8+CE=", + "dev": true + }, + "lodash._getnative": { + "version": "3.9.1", + "resolved": "https://registry.npmjs.org/lodash._getnative/-/lodash._getnative-3.9.1.tgz", + "integrity": "sha1-VwvH3t5G1hzc3mh9ZdPuy6o6r/U=", + "dev": true + }, + "lodash._isiterateecall": { + "version": "3.0.9", + "resolved": "https://registry.npmjs.org/lodash._isiterateecall/-/lodash._isiterateecall-3.0.9.tgz", + "integrity": "sha1-UgOte6Ql+uhCRg5pbbnPPmqsBXw=", + "dev": true + }, + "lodash.create": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/lodash.create/-/lodash.create-3.1.1.tgz", + "integrity": "sha1-1/KEnw29p+BGgruM1yqwIkYd6+c=", + "dev": true, + "requires": { + "lodash._baseassign": "3.2.0", + "lodash._basecreate": "3.0.3", + "lodash._isiterateecall": "3.0.9" + } + }, + "lodash.isarguments": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz", + "integrity": "sha1-L1c9hcaiQon/AGY7SRwdM4/zRYo=", + "dev": true + }, + "lodash.isarray": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/lodash.isarray/-/lodash.isarray-3.0.4.tgz", + "integrity": "sha1-eeTriMNqgSKvhvhEqpvNhRtfu1U=", + "dev": true + }, + "lodash.keys": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-3.1.2.tgz", + "integrity": "sha1-TbwEcrFWvlCgsoaFXRvQsMZWCYo=", + "dev": true, + "requires": { + "lodash._getnative": "3.9.1", + "lodash.isarguments": "3.1.0", + "lodash.isarray": "3.0.4" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "1.1.8" + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "dev": true + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "dev": true, + "requires": { + "minimist": "0.0.8" + } + }, + "mocha": { + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-3.5.3.tgz", + "integrity": "sha512-/6na001MJWEtYxHOV1WLfsmR4YIynkUEhBwzsb+fk2qmQ3iqsi258l/Q2MWHJMImAcNpZ8DEdYAK72NHoIQ9Eg==", + "dev": true, + "requires": { + "browser-stdout": "1.3.0", + "commander": "2.9.0", + "debug": "2.6.8", + "diff": "3.2.0", + "escape-string-regexp": "1.0.5", + "glob": "7.1.1", + "growl": "1.9.2", + "he": "1.1.1", + "json3": "3.3.2", + "lodash.create": "3.1.1", + "mkdirp": "0.5.1", + "supports-color": "3.1.2" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "requires": { + "wrappy": "1.0.2" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "supports-color": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-3.1.2.tgz", + "integrity": "sha1-cqJiiU2dQIuVbKBf83su2KbiotU=", + "dev": true, + "requires": { + "has-flag": "1.0.0" + } + }, + "type-detect": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-1.0.0.tgz", + "integrity": "sha1-diIXzAbbJY7EiQihKY6LlRIejqI=", + "dev": true + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + } + } +}