im supposed to save the json data from the a5.json file into a variable Called rects. I have the feeling I did it wrong. Im supposed to display the rectangles through the rects variable. how do I do that?
<script src="a5.json" defer></script>
<canvas id="c" width="500" height="500"></canvas>
var canvas = document.getElementById("c");
var context = canvas.getContext("2d");
var json = [{x: "50", y: "50", w: "100", h: "50", f: true }, { x: "50", y: "150", w: "100", h: "50", f: false }];
var rects = json;
context.lineWidth = 2;
context.strokeStyle = "#FF0000";
context.fillStyle = "#FF0000";
json.forEach(shape =>
{
context[shape.f === true ? 'fillRect' : 'strokeRect'](shape.x, shape.y, shape.w, shape.h);
}
);