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 trial

JavaScript

Hannah Cherba
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Hannah Cherba
Front End Web Development Techdegree Graduate 14,319 Points

404 error in chrome console. Not allowing me to run program.

Hello, I completed an assignment in my workspace and it ran just fine, but then when I was completing another assignment, it wouldn't let me run the code. The 404 error message kept coming up in the console. I tried to run my previous program in the workspace, to make sure it wasn't a syntax error, but it got the same message (even though I hadn't made any changes to the code and had updated the html file). I updated my mac and chrome, shut down my computer, tried running the same workspace on another computer, and nothing has worked. I even tried running another program I had made from a previous workspace (that had run perfectly before) and it wouldn't run. The same error message kept popping up in the console: Failed to load resource: the server responded with a status of 404 (Not Found) /favicon.ico:1

Any help would be much appreciated...I've spent the last few hrs trying to figure this out.

Thank you, Hannah

Bella Bradbury
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Bella Bradbury
Front End Web Development Techdegree Graduate 32,790 Points

Hello Hannah! We'll need the complete code to be able to assist you. It can be so frustrating when something's not working correctly, to help you we'll need to try replicating the issue.

Hannah Cherba
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Hannah Cherba
Front End Web Development Techdegree Graduate 14,319 Points
var num1;
var num2;
var message;

// announce the program
alert("Let's do some math!");

// collect numeric input
num1 = prompt("Please type a number");
num1 = parseFloat(num1);
num2 = prompt("Please type another number");
num2 = parseFloat(num2);
if ( num2 === 0 ) { 
  alert("The second number is 0. You can't divide by zero. Reload and try again.");
} else if ( isNaN(num1) || isNaN(num2) ) {
  alert("At least one of the values you typed is not a number. Reload and try again."); 
} else {
  message = "<h1>Math with the numbers " + num1 + " and " + num2 + "</h1>";
message += num1 + " + " + num2 + " = " + (num1 + num2);
message += "<br>";
message += num1 + " * " + num2 + " = " + (num1 * num2);
message += "<br>";
message += num1 + " / " + num2 + " = " + (num1 / num2);
message += "<br>";
message += num1 + " - " + num2 + " = " + (num1 - num2);

// write message to web page
document.write(message); } 
/* And then the code for the html:
<!DOCTYPE html>
<html>
  <head>

    <meta charset="utf-8">
    <title>JavaScript Numbers</title>
    <link href="css/style.css" rel="stylesheet"> 
  </head>
  <body>
    <main></main>
    <script src="js.random.js"></script>  
  </body>
</html>

Thank you!
*/

1 Answer

Steven Parker
Steven Parker
231,236 Points

On the line: <script src="js.random.js"></script>, if your file is named random.js and is located in a directory named js, then the source attribute should be: src="js/random.js" (note the slash instead of a period).

Otherwise, this appears to work just fine. But there could be some other issue based on file organization. When you need help with a workspace problem, always make a snapshot of your workspace and post the link to it here.