Exerpad
Exercise 6 · Chapter: Pixel ProjectsOptional+50 XP

Triangle

Read a number N from input and create an N x N grid with a right triangle.

The top-left corner is the right angle. Row i should have i + 1 green cells, the rest white.

Don't change the console.log statements at the bottom.

Expected output
8
green
white
green
Need a hint?
3 available · costs 5 XP each
javascript
let n = Number(prompt());
let grid = [];
// Create an N x N grid
// If col <= row: "green", else: "white"


let __grid__ = grid;

// Don't change below this line
console.log(grid.length);
console.log(grid[0][0]);
console.log(grid[0][n - 1]);
console.log(grid[n - 1][0]);
Output
Run your code to see the output here.