// ******************************* WARNING!!! WARNING!!! |
|
script.js |
// STEP 1: // Wrap the entire contents of script.js inside of an IIFE // See Lecture 52, part 2 // (Note, Step 2 will be done in the SpeakHello.js file.) |
SpeakHello.js |
// STEP 2: Wrap the entire contents of SpeakHello.js inside of an IIFE |
SpeakHello.js | // STEP 3: Create an object, called 'helloSpeaker' to which you will attach
// the "speak" method and which you will expose to the global context // DO NOT attach the speakWord variable to the 'helloSpeaker' object. |
SpeakHello.js | // STEP 4: Rewrite the 'speak' function such that it is attached to the
// helloSpeaker object instead of being a standalone function.
function speak(name) { |
SpeakHello.js | // 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; |
SpeakGoodBye.js |
// NOTE! The steps in this file are basically identical to the ones you // STEP 6: Wrap the entire contents of SpeakGoodBye.js inside of an IIFE |
SpeakGoodBye.js | // STEP 7: Create an object, called 'byeSpeaker' to which you will attach
// the "speak" method and which you will expose to the global context // DO NOT attach the speakWord variable to the 'byeSpeaker' object. |
SpeakGoodBye.js | // 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) { |
SpeakGoodBye.js | // STEP 9: Expose the 'byeSpeaker' object to the global scope. Name it // 'byeSpeaker' on the global scope as well. // xxxx.xxxx = byeSpeaker; |
script.js | // STEP 10: // Loop over the names array and say either 'Hello' or "Good Bye" // using the 'speak' method or either helloSpeaker's or byeSpeaker's // 'speak' method. // See Lecture 50, part 1 // for (/* fill in parts of the 'for' loop to loop over names array */) { |
script.js |
// STEP 11: |
script.js | // STEP 12: // Compare the 'firstLetter' retrieved in STEP 11 to lower case // 'j'. If the same, call byeSpeaker's 'speak' method with the current name // in the loop. Otherwise, call helloSpeaker's 'speak' method with the current // name in the loop. if (/* fill in condition here */) { // byeSpeaker.xxxx } else { // helloSpeaker.xxxx } |