JavaScript JavaScript Basics (Retired) Introducing JavaScript Your First JavaScript Program

Taylor Han
Taylor Han
3,701 Points

Cannot find variable?

Hello, I am in the first stages of the fullstack Javascript course. I am trying to write a sentence into the script, but each time I try to it tells me that it cannot find the variable for "write." I have gone back and rewatched the previous videos but cannot figure out what I am doing wrong.

Thank you

index.html
<!DOCTYPE HTML>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>JavaScript Basics</title>
</head>

<body>
</body>

<script>
// script.write();
  script.write("Welcome to my site");

</script>

</html>

Hi Taylor

From what I can see, you are trying to call the .write() method on an object called 'script' which isn't defined and doesn't exist. Try to call the write() method on the global document object. document.write('Welcome to my site');

Let me know if that works!

Antonio De Rose
Antonio De Rose
20,877 Points

lukehegarty give your answer in the answer area, your answer could be the best answer.

2 Answers

Taylor Han
Taylor Han
3,701 Points

Thank you Luke, that worked!

Copying answer into the correct place!

Hi Taylor

From what I can see, you are trying to call the .write() method on an object called 'script' which isn't defined and doesn't exist. Try to call the write() method on the global document object. document.write('Welcome to my site');

Let me know if that works!