Hi I'm working on a react project in which I have to generate random ids so I made this function
const idGenerator = () =>{
Math.floor(Math.random() * 1000000)
}
when I'm using it directly like this it works fine generates different ids
{
id:Math.floor(Math.random() * 1000000)
}
but when I make function and use it like this it generates the same id why is that?
const idGenerator = () =>{
Math.floor(Math.random() * 1000000)
}
// using it to make an object
{
id: idGenerator
}