vendredi 27 janvier 2023

How to extract random element from an array - Node.js [duplicate]

I am doing a project in JS and Node.js and I need to extract a random element from my array and then display it.

// enemies.js
const enemies = [
  "Wizard Monster",
  "Ice Golem",
  "Electro Dragon",
  "Fire Giant",
  "Rahzar Mutant",
]
export default enemies

// fight.js
import enemies from "../utils/enemies.js"

// Code here

Any ideas ?

Thanks in advance.




Aucun commentaire:

Enregistrer un commentaire