I want to test if a local_key
already exists, if it exists generate another local_key
and check again
// Here I go throught an object and try to return a index
const local_key = messagesRow.map((message, key) => {
return message.local_key;
}).indexOf(message.local_key);
// If it returns 0 or bigger, it means that the local_key already exists
if(local_key >= 0){
message.local_key = Math.floor(Math.random() * 9999);
}
EDIT
I want to recheck every time, cause if the local_key
exists and I generate another one, this new local_key
maybe exists too