JavaScript checkerboard

Hello,
I have a web programming project to submit.
There's a question where I'm stuck: Complete the style for the style tag of the document to define a black square and a white square, and use this style for the squares of the checkerboard.
Note: an HTML tag can have multiple CSS classes!
Tip: the sum of the coordinates of the squares modulo 2 (the remainder of the division by 2) tells you whether it's a white square or a black square.
How can we do this? Does anyone have a clue??
Thanks!

Configuration: Windows / Chrome 98.0.4758.102

2 answers

  1. Moderator
    Hello
    You should already have the HTML and JavaScript code you started writing

    --
    .
    Best regards,
    Jordane
    0
    1. "Complete the style of the style tag of the document
      so it's a matter of CSS and not JavaScript.

      Tip: there is an even or odd selector

      Otherwise:
      "How can we do this? Does anyone have a lead??"
      Tip: the sum of the coordinates of the squares modulo 2 (the remainder of the division by 2) indicates whether it's a white square or a black square.

      Or simply check if a value is even, its result from division by two is the same for its integer value; for an odd number it is not:

      3/2 = 1.5
      2/2 =1

      IF Math.int(result)==result) => then even number
      => ELSE odd number

      even better with modulo which allows obtaining the modulo of a number
      https://en.wikipedia.org/wiki/Modulo_operation"
      0