Skip to content

Commit 5dea335

Browse files
committed
IFFE created
1 parent c0d446e commit 5dea335

File tree

1 file changed

+37
-23
lines changed

1 file changed

+37
-23
lines changed

5-advanced-JS/starter/script.js

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -116,27 +116,41 @@
116116
// console.log(rates);
117117

118118
//Functions returning another function
119-
function interviewQuestion(job){
120-
if (job === 'designer') {
121-
return function(name) {
122-
console.log(name, ', Can you please explain what UX design is?')
123-
}
124-
} else if(job === 'teacher') {
125-
return function(name){
126-
console.log('what subject do you teach', name);
127-
}
128-
} else {
129-
return function(name) {
130-
console.log('Hello', name, 'what do you do?');
131-
}
132-
}
133-
}
134-
135-
var teacherQuestion = interviewQuestion('teacher');
136-
var designerQuestion = interviewQuestion('designer');
137-
138-
teacherQuestion('John');
139-
designerQuestion('Jane');
140-
141-
interviewQuestion('teacher')('Mark');
119+
// function interviewQuestion(job){
120+
// if (job === 'designer') {
121+
// return function(name) {
122+
// console.log(name, ', Can you please explain what UX design is?')
123+
// }
124+
// } else if(job === 'teacher') {
125+
// return function(name){
126+
// console.log('what subject do you teach', name);
127+
// }
128+
// } else {
129+
// return function(name) {
130+
// console.log('Hello', name, 'what do you do?');
131+
// }
132+
// }
133+
// }
134+
135+
// var teacherQuestion = interviewQuestion('teacher');
136+
// var designerQuestion = interviewQuestion('designer');
137+
138+
// teacherQuestion('John');
139+
// designerQuestion('Jane');
140+
141+
// interviewQuestion('teacher')('Mark');
142+
143+
//IIFE
144+
//Immediatlt Invoked Function
145+
146+
// function game() {
147+
// var score = Math.random() * 10;
148+
// console.log(score >= 5);
149+
150+
// }
151+
// game();
142152

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

0 commit comments

Comments
 (0)