Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
fixed
  • Loading branch information
annagabain committed Aug 14, 2019
commit e5d3c83baed1d4d594cc3a9a2ce97264c9c12a79
14 changes: 14 additions & 0 deletions Week3/homework/MY-step2-1-Foo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict';

function foo(func) {
func()
console.log(func);
}

function bar() {
console.log('Hello, I am bar!');
}
foo(bar);

// Do not change or remove anything below this line
module.exports = foo;
5 changes: 2 additions & 3 deletions Week3/homework/MY-step2-7-Different_Results.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,5 @@ console.log(y);

// Add your explanation as a comment here

//x is 9 and does not change after the f1 function is executed but it does if I console.log(f1(x)), I do not know why. Maybe because x was defined outside of the f1 function scope

//y is returned after going through the f2 function where the value of y(that is an object containing x) is changed by adding 1 to x. 9+1=10
// in function f1 x is passed by value, therefore does not change
//in function f2 x is passed by reference, y is returned after going through the f2 function where the value of y(that is an object containing x) is changed by adding 1 to x. 9+1=10