Skip to content

jan12th #2

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.

6 changes: 1 addition & 5 deletions paperproblems/anonymous-functions/problem1.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
Rewrite this program so that it doesn't have a single function definition
In other words, replace all the function definitions with anonymous functions

function greet(x) {
console.log("hello " + x);
}

greet(bob);
(function (x) {console.log("hello " + x);})('bob');
9 changes: 2 additions & 7 deletions paperproblems/anonymous-functions/problem3.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
Rewrite this program so that it doesn't have a single function definition
In other words, replace all the function definitions with anonymous functions

function greet(x, y) {
console.log("hello " + x + " " + y);
}

function call(f) {
f("Bob", "Dole");
}

call(greet);
(function (f) {f("Bob", "Dole");})
(function (x, y) {console.log("hello " + x + " " + y);})
10 changes: 2 additions & 8 deletions paperproblems/anonymous-functions/problem4.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
Rewrite this program so that it doesn't have a single function definition
In other words, replace all the function definitions with anonymous functions

function greet(x) {
console.log("hello " + x);
}

function twice(f) {
(function (f) {
f("bob");
f("mary");
}

twice(greet);
})(function (x) {console.log("hello " + x);})
15 changes: 13 additions & 2 deletions paperproblems/constructor-functions/problem5.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
Rewrite this program so that it does't use the new keyword.
The program must be equivalent in every other way.

function Person(name, age) {
function Person(myname, myage) {
return {name : myname,
age : myage,
greet : function() {
console.log("Hello my name is " + this.name);
}}
}

var bob = Person("Bob", 30)
bob.__proto__ = Person.prototype

//function Person(name, age) {
this.name = name;
this.age = age;
this.greet = function() {
console.log("Hello my name is " + this.name);
}
}

var bob = Person("Bob", 30);
var bob = new Person("Bob", 30);//
Loading