Use basic JavaScript

This program should draw the French national flag. It should fill the entire canvas, regardless the canvas size.

The left third of the flag is blue, the middle third is white, and the right third is red. You will need to use Rectangle objects in this program and the color format of Color.[color] in order to pass the Test Cases.

3 answers

// Create a canvas
const canvas = document.createElement('canvas');
document.body.appendChild(canvas);

// Get the canvas context
const ctx = canvas.getContext('2d');

// Get the canvas width and height
const width = canvas.width;
const height = canvas.height;

// Create the Rectangle objects
const blueRect = new Path2D();
blueRect.rect(0, 0, width / 3, height);

const whiteRect = new Path2D();
whiteRect.rect(width / 3, 0, width / 3, height);

const redRect = new Path2D();
redRect.rect(2 * width / 3, 0, width / 3, height);

// Draw the Rectangles
ctx.fillStyle = 'blue';
ctx.fill(blueRect);

ctx.fillStyle = 'white';
ctx.fill(whiteRect);

ctx.fillStyle = 'red';
ctx.fill(redRect);
I JUST RAN THIS AND IT ACTUALLY WORKS!!!!!!!!!!

WHAT IN THE WORLD!!!!!!!
not sure if anyone is reading this, but the fact that someone asked for a french flag in js, and then they got it instantly.

this changes everything. i cannot believe it
Similar Questions
    1. answers icon 1 answer
  1. 1. Look at the Canadian national flag.2. Look at the national flag of Canada. 3. This is the Chinese national flag. 4. This is
    1. answers icon 2 answers
    1. answers icon 1 answer
  2. What do we use control structures for in JavaScript?Control the flow of the program; how the commands execute. Start our
    1. answers icon 1 answer
more similar questions