Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. import React, { Component } from "react";
  2. import Pokedex from "./Pokedex";
  3.  
  4. class Pokegame extends Component {
  5. static defaultProps = {
  6. pokemon: [
  7. { id: 4, name: "Charmander", type: "fire", experience: 62 },
  8. { id: 7, name: "Squirtle", type: "water", experience: 63 },
  9. { id: 11, name: "Metapod", type: "bug", experience: 72 },
  10. { id: 12, name: "Butterfree", type: "flying", experience: 178 },
  11. { id: 25, name: "Pikachu", type: "electric", experience: 112 },
  12. { id: 39, name: "Jigglypuff", type: "normal", experience: 95 },
  13. { id: 94, name: "Gengar", type: "poison", experience: 225 },
  14. { id: 133, name: "Eevee", type: "normal", experience: 65 }
  15. ]
  16. };
  17.  
  18. render() {
  19. let hand1 = [];
  20. let hand2 = [...this.props.pokemon];
  21.  
  22. while (hand1.length < hand2.length) {
  23. let randIndex = Math.floor(Math.random() * hand2.length);
  24. let randPokemon = hand2.splice(randIndex, 1)[0];
  25. hand1.push(randPokemon);
  26. }
  27.  
  28. console.log(hand1);
  29. console.log(hand2);
  30.  
  31. return (
  32. <div className="Pokegame">
  33. <h1>Pokegame!</h1>
  34. </div>
  35. );
  36. }
  37. }
  38.  
  39. export default Pokegame;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement