mardi 6 novembre 2018

Getting half of an string array at random no matter array size

I am trying to create a function that takes half of the names at random and spits them back out. I would like to be able to enter them on the site instead of inside of the code each time I want to be able to add a name to the list any suggestions would be aprpreciated. This is what I have currently: `import React from 'react'; import ReactDOM from 'react-dom'; class Shuffle extends React.Component {

render() {

var shuffle = require('shuffle-array')

return (

  <h1>{shuffle.pick(['Kevin ','Bill ','Chuck ','Tom ','Joe ', 'Mike '], { 'picks':  2 })}</h1>

);

} } export default Shuffle;




Aucun commentaire:

Enregistrer un commentaire