TGViewer
As For JS As For JS @asforjavascript · 3.08K subscribers
Post #1050 1.88K
Чтобы Вы в этом коде, назвали бы отвратительным и как бы Вы его (код или часть его) переписали

const dashboardConfig = [{
id: 'filters',
gridAttributes: {
width: 6,
height: 1,
yPos: 0,
xPos: 3,
},
}, {
id: 'info',
gridAttributes: {
width: 3,
height: 2,
yPos: 1,
xPos: 1,
},
}, {
id: 'more',
gridAttributes: {
width: 4,
height: 1,
yPos: 2,
xPos: 7,
},
}, ];

const columns = 12
const rows = Math.max(...dashboardConfig.map( ({gridAttributes}) => gridAttributes.yPos + gridAttributes.height), );

console.log(rows)

const grid = Array.from({
length: rows
}, () => Array.from({
length: columns
}).fill('.'))

dashboardConfig.forEach( (entry) => {
const {id, gridAttributes} = entry
const {xPos, yPos, width, height} = gridAttributes

for (let i = 0; i < width; i++) {
for (let j = 0; j < height; j++) {
grid[yPos + j][xPos + i] = id
}
}
}
)

const result = grid.map( (row) => `"${row.join(' ')}"`).join('\n')

console.log( result );
  • ❤ 2
  • 👨‍💻 2
More from @asforjavascript
  1. Oct 8, 2026https://www.youtube.com/watch?v=ItxfZCmdaSI&list=OLAK5uy_lVqIIi_ibuhCtw6SMTo6bUpeJ6iyVXGuM…
  2. Oct 6, 2026https://youtu.be/rfUEstWJUkA?si=8oyCWfdr2omi69ay
  3. Oct 5, 2026Я все еще еще... Запомните меня таким.
  4. Oct 3, 2026Доброго вам Утрааааа
  5. Oct 3, 2026Архив орг, вводит ограничение до двух публикаций в месяц от одного автора. https://blog.ar…
  6. Oct 2, 2026Если я пропустил за предыдущие 100500 сообщений, что-то, что было для Вас важно - тыкнете…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →