Exercise 10 · Chapter: Pixel ProjectsOptional+50 XP
Diagonal Stripes
Read a number N from input and create an N x N grid with diagonal stripes.
Use (row + col) % 3 to pick the color:
0→"red"1→"gold"2→"orange"
Don't change the console.log statements at the bottom.
Expected output
6 red gold orange
Need a hint?
3 available · costs 5 XP each
javascript
let n = Number(prompt());
let colors = ["red", "gold", "orange"];
let grid = [];
// Create N x N grid
// Use colors[(row + col) % 3] for each cell
let __grid__ = grid;
// Don't change below this line
console.log(grid.length);
console.log(grid[0][0]);
console.log(grid[0][1]);
console.log(grid[1][1]);
Output
Run your code to see the output here.