Exerpad
Exercise 8 · Chapter: Pixel ProjectsOptional+50 XP

Rhombus

Read an odd number N from input and create an N x N grid with a rhombus (diamond) shape.

A cell is inside the rhombus if Math.abs(row - center) + Math.abs(col - center) <= center, where center = Math.floor(n / 2).

Use "blue" for the rhombus and "white" for the background.

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

Expected output
7
white
blue
blue
Need a hint?
3 available · costs 5 XP each
javascript
let n = Number(prompt());
let center = Math.floor(n / 2);
let grid = [];
// Create N x N grid
// If Math.abs(row - center) + Math.abs(col - center) <= center: "blue"
// Otherwise: "white"


let __grid__ = grid;

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