Advertisement
Guest User

Untitled

a guest
Dec 19th, 2022
379
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React from 'react';
  2. import ReactDOM from 'react-dom/client';
  3.  
  4. import './index.css'
  5.  
  6. function Block(props) {
  7.   return (
  8.     <div className={"block" + props.color}></div>
  9.   );
  10. }
  11.  
  12. function Grid(props) {
  13.   let blocks = [];
  14.  
  15.   for(let i = 0; i < 18; i++) {
  16.     for (let j = 0; j < 18; j++) {
  17.       blocks.push (
  18.         // change code below this line
  19.         <Block key={`(${i}, ${j})`} color={(i + j) % 2 == 0 ? ' lightblue' : ''} />
  20.         // change code above this line
  21.       )
  22.     }
  23.   }
  24.  
  25.   return (
  26.     <div id="grid">{blocks}</div>
  27.   );
  28. }
  29.  
  30. const root = ReactDOM.createRoot(document.getElementById('root'));
  31. root.render(<Grid />);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement