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 trialolu adesina
23,007 Pointskeep getting an error in my displayMovieName(); function help
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<header>
<h1>Movie Rating Game</h1>
</header>
<div>
<h2 id="movie_title"></h2>
<div>
Enter your Name and start game:
<input id="playerName" type="text" name="name">
<input type="submit" value="Submit" onclick="collectName()">
</div>
</div>
</body>
<script >
/ Define playerName as Null //
var playerName = null;
// Define collectName Function //
var collectName = function(){
// Set Player Name equal to Input Value #playerName //
playerName = document.getElementById('playerName').value;
displayMovieName();
}
function movie(name,rating,image){
this.name=name
this.rating=rating
this.image=image
}
manOfSteel = new movie('Man of Steel','3/5','images/mos.jpg')
function displayMovieName(){
var element = document.getElementById('movie_title')
element.innerHTML = manOfSteel.name; // getting an error here not sure why
}
</script>
</html>
1 Answer
Martin Zarate
10,723 PointsAt the very beginning of your script, you are missing one '/' for the comment:
<script >
// Define playerName as Null //
var playerName = null;
Cheers.