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 trialAngela Pintus
400 PointsCode does not work.
I have understood the instructions but code does not work! I have written the same code of the professor! In the js file: alert("Let's do some math!"); var firstNumber = prompt("Enter a number: "); firstNumber = parseFloat(firstNumber); var secondNumber = prompt("Enter a number: "); secondNumber = parseFloat(secondNumber); var message = "<h1>Math with the numbers " + firstNumber + " and " + secondNumber + "</h1>"; document.write(message);
In the html file: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Practice JavaScript Math</title> <link href="css/styles.css" rel="stylesheet"> </head> <body> <script src="js/math.js></script> </body> </html>
Kevin Gates
15,053 PointsNext time, please use the Markdown cheatsheet to make your code more readable, like this:
JS File
alert("Let's do some math!");
var firstNumber = prompt("Enter a number: ");
firstNumber = parseFloat(firstNumber);
var secondNumber = prompt("Enter a number: ");
secondNumber = parseFloat(secondNumber);
var message = "<h1>Math with the numbers " + firstNumber + " and " + secondNumber + "</h1>";
document.write(message);
HTML File
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Practice JavaScript Math</title>
<link href="css/styles.css" rel="stylesheet">
</head>
<body>
<script src="js/math.js></script>
</body>
</html>
2 Answers
Angela Pintus
400 PointsI posted my code. I want check if my code works first, then I'll add the rest of the code to complete the challenge.
Angela Pintus
400 PointsIt works, there was a problem in html file. I have re written the script in the html file. That's weird!
KRIS NIKOLAISEN
54,972 PointsYou are missing a closing quote here:
<script src="js/math.js>
in your html. Should be
<script src="js/math.js">
Angela Pintus
400 PointsWhere? I put the closing quote, it's an error of workplace, it does not work well.
KRIS NIKOLAISEN
54,972 PointsKRIS NIKOLAISEN
54,972 PointsCan you post your code?