Reputation: 131
I am taking my first JavaScript class. The first two exercises I did worked great. This one however is not. Nothing all all shows up in the browser. It is just a white page. Any suggestions would be greatly appreciated.
<!DOCTYPE html PUBLIC "_//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<script type="text/javascript">
var degFahren = Number(prompt("Enter the degrees Fahrenheit",32));
var degCent;
degCent = 5/9 * (degFahren - 32));
document.write(degFahren + "\xB0 Fahrenheit is " + degCent + "\xB0 centigrade<br />";
if (degCet < 0) { document.write("That's below the freezing point of water");}
if (degCent == 100) { document.write("That's the boiling point of water"); }
</script>
</body>
</html>
Upvotes: 0
Views: 142
Reputation: 25634
This code should work. These are easy to spot problems, just open up your javascript console (F12) and you'll see you have an extra )
on line 8, and a missing one line 10. There was also a typo on degCent
.
<!DOCTYPE html PUBLIC "_//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<script type="text/javascript">
var degFahren = Number(prompt("Enter the degrees Fahrenheit",32));
var degCent;
degCent = 5/9 * (degFahren - 32);
document.write(degFahren + "\xB0 Fahrenheit is " + degCent + "\xB0 centigrade<br />");
if (degCent < 0) { document.write("That's below the freezing point of water");}
if (degCent == 100) { document.write("That's the boiling point of water"); }
</script>
</body>
</html>
Upvotes: 6