-10

I want to randomly generate a number between 1 and 10 and also display it on a webpage, does anyone have any idea how i'd go about doing this?

preferably in full since i have no idea what im doing

  • 1
    possible duplicate of [Generating random numbers in Javascript in a specific range?](http://stackoverflow.com/questions/1527803/generating-random-numbers-in-javascript-in-a-specific-range) – summea Apr 09 '14 at 21:05
  • https://www.google.com/search?q=javascript+generate+random+number&rlz=1C1CHMO_enUS499US499&oq=javascript+gener&aqs=chrome.4.69i57j0l5.5458j0j7&sourceid=chrome&espv=210&es_sm=122&ie=UTF-8#q=javascript+generate+random+number – Dryden Long Apr 09 '14 at 21:05
  • 2
    Welcome to StackOverflow! As you've probably guessed by now, asking questions like this is frowned upon because you appear to not have tried. I recommend you have a look at https://developer.mozilla.org - this is (imho) a great resource for using web technologies. Good luck! – Simon Apr 09 '14 at 21:09
  • "*i have no idea what im doing*," well there's your problem. Look, we've all been there before, but you need to do some research yourself before you ask a question on SO. At least show us what you've tried. – p.s.w.g Apr 09 '14 at 21:12

1 Answers1

4

C'mon man. Google something. jsfiddle

var min = 1, max = 10,
    num = Math.floor(Math.random() * (max - min + 1)) + min;

document.body.innerHTML = num;
Mulan
  • 129,518
  • 31
  • 228
  • 259