Skip to content

exercises for HOF, __proto__, return and exceptions #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
326 changes: 326 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion paperproblems/anonymous-functions/problem1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ function greet(x) {
console.log("hello " + x);
}

greet(bob);
greet(bob);

var greet = function(x){ console.log("hello " + x);}
greet = "bob";
2 changes: 2 additions & 0 deletions paperproblems/anonymous-functions/problem2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ function call(f) {
}

call(greet);

(function(f){f("bob");})(function(x){console.log("hello " + x);})
2 changes: 2 additions & 0 deletions paperproblems/anonymous-functions/problem3.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ function call(f) {
}

call(greet);

(function(f){f("bob","dole");})(function(x,y){console.log("hello " + x + " " + y);})
4 changes: 3 additions & 1 deletion paperproblems/anonymous-functions/problem4.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ function twice(f) {
f("mary");
}

twice(greet);
twice(greet);

(function(f){f("bob");f("mary")})(function(x){console.log("hello " + x);})
6 changes: 4 additions & 2 deletions paperproblems/anonymous-functions/problem5.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@ function soften(f) {
}

var softAskOnADate = soften(askOnADate);
console.log(softAskOnADate("Eric"));
console.log(softAskOnADate("Bob"));
console.log(softAskOnADate("Eric")); --> maybe
console.log(softAskOnADate("Bob"));--> I do!


14 changes: 7 additions & 7 deletions paperproblems/arrow-functions/problem1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 // no syntax error -- inputs x and adds 1

b) x, y => x * y
b) x, y => x * y // x is not defined

c) x => { x * 2 }
c) x => { x * 2 } //no syntax error -- inputs x and multiplies by 2

d) (x, z) => {console.log(z); return x * z}
d) (x, z) => {console.log(z); return x * z} //no syntax error -- prints z and then returns z multiplied by x

e) x => console.log(z); return x * z
e) x => console.log(z); return x * z // return is outside of the function

f) (x) => x * 2
f) (x) => x * 2 // will return x multiplied by 2

e) () => console.log("hello")
e) () => console.log("hello") // prints out hello

When you're done, check all your answers in the developer console.
Loading