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 trialTaylor Han
3,701 PointsCannot 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
<!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>
Antonio De Rose
20,885 Pointslukehegarty give your answer in the answer area, your answer could be the best answer.
2 Answers
Taylor Han
3,701 PointsThank you Luke, that worked!
lukehegarty
7,497 PointsCopying 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!
lukehegarty
7,497 Pointslukehegarty
7,497 PointsHi 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!