-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
21 lines (17 loc) · 677 Bytes
/
Copy pathscript.js
File metadata and controls
21 lines (17 loc) · 677 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// IIFE to create function that displays "Good Bye" + " " + "name" for names that begin with J and
// "Hello" + " " + "name" for names that begin with other letters
//IIFE
(function(){
var names = ["Yaakov", "John", "Jen", "Jason", "Paul", "Frank", "Larry", "Paula", "Laura", "Jim"];
//loop through all the names
for (var indx in names) {
//select lowercase of firt letter from name array
var firstLetter = names[indx].charAt(0).toLowerCase();
//call byeSpeaker for letters that begin with "j" else call helloSpeaker
if (firstLetter === 'j') {
byeSpeaker.speak(names[indx]);
} else {
helloSpeaker.speak(names[indx]);
}
}
})();