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

Creating a Random Number Generator with JavaScript but isn't working and I don't know why, help?????

I've been following along with The Random Challenge and I legit have written THE EXACT SAME as Dave McFarland, but when I Preview the Workspace it comes up with the box to input a number but after that nothing else happens and I really don't know why.

My HTML

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <link rel="stylesheet" href="css/main.css">
  <title>JavaScript Basics</title>
 </head>
<body>
  <div class="container">
  <h1>Random Number Generator</h1>
   <script src="random.js"></script> 
  </div>
</body>
</html>

My JS

var input = prompt("Please type a number");
var topNumber = parseInt(input);
var randomNumber = math.floor(math.random() * topNumber) +1;
var message = "<p>" + randomNumber + " is a number between 1 and " + topNumber + ".</p>";
document.write(message);

HELP MEEEEEEEEEEE:)

1 Answer

FIGURED IT OUT! Suddenly clocked that I didn't use a capital M for my Math.'s. So for anyone else with a similar situation, make sure you're using your capitals when need be applicable. Bless me.