-
Notifications
You must be signed in to change notification settings - Fork 0
/
SpeakHello.js
37 lines (27 loc) · 1.05 KB
/
SpeakHello.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// STEP 2: Wrap the entire contents of SpeakHello.js inside of an IIFE
// See Lecture 52, part 2
// STEP 3: Create an object, called 'helloSpeaker' to which you will attach
// the "speak" method and which you will expose to the global context
// See Lecture 52, part 1
// var helloSpeaker =
// DO NOT attach the speakWord variable to the 'helloSpeaker' object.
//var speakWord = "Hello";
// STEP 4: Rewrite the 'speak' function such that it is attached to the
// helloSpeaker object instead of being a standalone function.
// See Lecture 52, part 2
// function speak(name) {
// console.log(speakWord + " " + name);
// }
// STEP 5: Expose the 'helloSpeaker' object to the global scope. Name it
// 'helloSpeaker' on the global scope as well.
// See Lecture 52, part 2
// (Note, Step 6 will be done in the SpeakGoodBye.js file.)
// xxxx.xxxx = helloSpeaker;
(function (window){
var helloSpeaker = {};
var speakWord = "Hello";
helloSpeaker.speak = function (name) {
console.log(speakWord + " " + name)
}
window.helloSpeaker = helloSpeaker;
})(window);