Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript Basics (Retired) Creating Reusable Code with Functions Creating a Function

Challenge Task 3 of 3 Call the new sayHi function you just created.

Everytime I submit the answer to the 3rd question of this quiz I receive the "Oops, communication error". I'm almost finished with the prerequisites but am afraid I might not finish due to this error! HELP!

script.js
function sayHi() {
  alert("Hi");

    sayHi();
}
index.html
<!DOCTYPE HTML>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>JavaScript Basics</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>

3 Answers

Deborah Bamidele
Deborah Bamidele
3,240 Points

Hi Devin. The problem is that you are calling the function inside the function itself. What you should do is call it outside the function block.

function sayHi() { alert("Hi"); }

sayHi();

Yep, just figured that out and it passed. Weird that it kept making the page lose connection though, right?

Deborah Bamidele
Deborah Bamidele
3,240 Points

Yeah. I guess there are tests in place that parses the code and makes sure the answer is correct, otherwise it throws an error.

Million Asseghegn
Million Asseghegn
3,845 Points

function sayHi() { alert("Hi"); } sayHi();