Why my Math.random generates same numbers?

I want to know why my Random number generator generates same number, i even did a while loop to stop the same generating numbers from generating, and once the 25 numbers are done generating it will restart again.
here is my html

<!DOCTYPE html>

<html lang="en">


    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <link rel="stylesheet" href="apping.css">



    <script src="app.js"></script>

   <div> <textarea readonly name="" id="area" cols="65" rows="10"></textarea></div>

    <button onclick="randomNumber(25)" id="gen"> Generate RNG </button>




and here is my javascript, any help would be apperciated

const list = []

function randomNumber(max) {

    const textArea = document.getElementById("area")

    const newRandomNumber = Math.floor(Math.random() * max + 1)

    textArea.value = newRandomNumber;

    while(list.length < 1 ){

        let nbr = newrandomNumber(25)

        if(!list.find(el => el === nbr)) list.push(nbr)




  textarea.value = list;

Welcome to the community!

Math.random() actually returns a pseudo-random number rather than a truly random number. It’s a bit tough to explain, but essentially if you want a truly random number you’ll need to use some other methods. I’d recommend searching online for how to make a truly random number in JavaScript, or how to change the seed every time.

You can read more about Math.random() here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random

You have a couple of (small) issues here - if you open the browser console, you can see the errors.

  1. textarea.value = list --> that line throws an error, because textarea is not defined. First, you’ve called the variable textArea (camelCase), second, you’ve defined it inside the function, and then try to access it from outside the function.

  2. let nbr = newrandomNumber(25) --> throws an error because first, again, you’ve defined the variable as newRandomNumber (camelCase), and second, it’s only a variable, not a function, so you can’t call it with brackets like newRandomNumber(25).

I’m not sure what’s the goal of your code, but if you fix these issues, you’ll get a new random number in your text area with each button click.