Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, { Component } from "react";
- import Pokedex from "./Pokedex";
- class Pokegame extends Component {
- static defaultProps = {
- pokemon: [
- { id: 4, name: "Charmander", type: "fire", experience: 62 },
- { id: 7, name: "Squirtle", type: "water", experience: 63 },
- { id: 11, name: "Metapod", type: "bug", experience: 72 },
- { id: 12, name: "Butterfree", type: "flying", experience: 178 },
- { id: 25, name: "Pikachu", type: "electric", experience: 112 },
- { id: 39, name: "Jigglypuff", type: "normal", experience: 95 },
- { id: 94, name: "Gengar", type: "poison", experience: 225 },
- { id: 133, name: "Eevee", type: "normal", experience: 65 }
- ]
- };
- render() {
- let hand1 = [];
- let hand2 = [...this.props.pokemon];
- while (hand1.length < hand2.length) {
- let randIndex = Math.floor(Math.random() * hand2.length);
- let randPokemon = hand2.splice(randIndex, 1)[0];
- hand1.push(randPokemon);
- }
- console.log(hand1);
- console.log(hand2);
- return (
- <div className="Pokegame">
- <h1>Pokegame!</h1>
- </div>
- );
- }
- }
- export default Pokegame;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement