From afe8d49a333276c5cb81b0a2fb5296b630913ae9 Mon Sep 17 00:00:00 2001 From: priyaahm <130679111+priyaahm@users.noreply.github.com> Date: Sun, 30 Jul 2023 22:00:12 +0530 Subject: [PATCH] update --- module-4 sol/SpeakGoodBye.js | 34 ++++++++++++++++++ module-4 sol/SpeakHello.js | 35 +++++++++++++++++++ module-4 sol/index.html | 15 +++++++- module-4 sol/script.js | 67 ++++++++++++++++++++++++++++++++++++ 4 files changed, 150 insertions(+), 1 deletion(-) create mode 100644 module-4 sol/SpeakGoodBye.js create mode 100644 module-4 sol/SpeakHello.js create mode 100644 module-4 sol/script.js diff --git a/module-4 sol/SpeakGoodBye.js b/module-4 sol/SpeakGoodBye.js new file mode 100644 index 0000000..bf92169 --- /dev/null +++ b/module-4 sol/SpeakGoodBye.js @@ -0,0 +1,34 @@ +// NOTE! The steps in this file are basically identical to the ones you +// performed in the SpeakHello.js file. + +// STEP 6: Wrap the entire contents of SpeakGoodBye.js inside of an IIFE +// See Lecture 52, part 2 + + +// STEP 7: Create an object, called 'byeSpeaker' to which you will attach +// the "speak" method and which you will expose to the global context +// See Lecture 52, part 1 +// var byeSpeaker = +var byeSpeaker = { + speak :function(){ + console.log("hi"); + } +}; + +// DO NOT attach the speakWord variable to the 'byeSpeaker' object. +(function(){ +var speakWord = "Good Bye"; + + +// STEP 8: Rewrite the 'speak' function such that it is attached to the +// byeSpeaker object instead of being a standalone function. +// See Lecture 52, part 2 +function speak(name) { + console.log(speakWord + " " + name); +} +})(); + +// STEP 9: Expose the 'byeSpeaker' object to the global scope. Name it +// 'byeSpeaker' on the global scope as well. +// xxxx.xxxx = byeSpeaker; +window.byeSpeaker = byeSpeaker; \ No newline at end of file diff --git a/module-4 sol/SpeakHello.js b/module-4 sol/SpeakHello.js new file mode 100644 index 0000000..0ed8c3b --- /dev/null +++ b/module-4 sol/SpeakHello.js @@ -0,0 +1,35 @@ +// 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 = +var helloSpeaker ={ + speak: function(){ + console.log("Hey"); + } +}; + +// DO NOT attach the speakWord variable to the 'helloSpeaker' object. +(function(){ + + +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. +window.helloSpeaker=helloSpeaker; +// See Lecture 52, part 2 +// (Note, Step 6 will be done in the SpeakGoodBye.js file.) +// xxxx.xxxx = helloSpeaker; +})(); \ No newline at end of file diff --git a/module-4 sol/index.html b/module-4 sol/index.html index 8b13789..98fc93d 100644 --- a/module-4 sol/index.html +++ b/module-4 sol/index.html @@ -1 +1,14 @@ - + + +
+ + +