Skip to content
Merged
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
Next Next commit
IFFE created
  • Loading branch information
mike-diff committed Nov 26, 2018
commit 5dea335b9a4584bbc4bf213a9d5b87a3c9bbb2ad
60 changes: 37 additions & 23 deletions 5-advanced-JS/starter/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,27 +116,41 @@
// console.log(rates);

//Functions returning another function
function interviewQuestion(job){
if (job === 'designer') {
return function(name) {
console.log(name, ', Can you please explain what UX design is?')
}
} else if(job === 'teacher') {
return function(name){
console.log('what subject do you teach', name);
}
} else {
return function(name) {
console.log('Hello', name, 'what do you do?');
}
}
}

var teacherQuestion = interviewQuestion('teacher');
var designerQuestion = interviewQuestion('designer');

teacherQuestion('John');
designerQuestion('Jane');

interviewQuestion('teacher')('Mark');
// function interviewQuestion(job){
// if (job === 'designer') {
// return function(name) {
// console.log(name, ', Can you please explain what UX design is?')
// }
// } else if(job === 'teacher') {
// return function(name){
// console.log('what subject do you teach', name);
// }
// } else {
// return function(name) {
// console.log('Hello', name, 'what do you do?');
// }
// }
// }

// var teacherQuestion = interviewQuestion('teacher');
// var designerQuestion = interviewQuestion('designer');

// teacherQuestion('John');
// designerQuestion('Jane');

// interviewQuestion('teacher')('Mark');

//IIFE
//Immediatlt Invoked Function

// function game() {
// var score = Math.random() * 10;
// console.log(score >= 5);

// }
// game();

(function(goodluck){
var score = Math.random() * 10;
console.log(score >= 5 - goodluck);
})(5);