I've been working on this for over 12 hours.
I really enjoy coding but I'm very bad at it.
Could you please highlight in red where I've gone wrong in this code?
(function (window) {
var names = {"Yaakov", "John", "Jen", "Jason", "Paul", "Frank", "Larry", "Paula", "Laura", "Jim"};
for (let i = 0; i < names.length; i++) {
if (firstLetter === 'j') || 'J'{
byeSpeaker.speak(names[i]);
} else {
helloSpeaker.speak(names[i]);
}
}
})(window);
(function (window) {
var speakWord = "Hello";
var helloSpeaker = speakWord;
helloSpeaker.speak(name) = fuction ()
(speakWord + " " + name);
window.helloSpeaker = helloSpeaker;
console.log(window);})
(function (window) {
var speakWord = "Good Bye";
var byeSpeaker = speakWord;
byeSpeaker.speak(name) = function () {
(speakWord + " " + name);}
window.byeSpeaker = byeSpeaker;
console.log(window);})
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Module 4 Solution Starter</title>
<script src="SpeakHello.js"></script>
<script src="SpeakGoodBye.js"></script>
<script src="script.js"></script>
</head>
<body>
<h1>Module 4 Solution Starter</h1>
</body>
</html>
It's supposed to loop for hello name but goodbye for names beginning with J.
If you can provide more feedback I would be grateful.
Thanks in advance.
Natasha
Your first if statement is bad. It should be like this:
if (firstLetter === 'j' || firstLetter === 'J') {