JavaScript JavaScript Basics Creating Reusable Code with Functions Creating a Function

call the new sayHi function you just created

script.js
fuction sayHi() {
alert("Hi");
};
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>

1 Answer

Steven Parker
Steven Parker
170,320 Points

It looks like you have a spelling error where the code has "fuction" instead of "function".

Then, to "call" a function, you write the function name and put parentheses after it (and then an optional semicolon for "best practice").