📜  为数组添加边框 - CSS 代码示例

📅  最后修改于: 2022-03-11 14:47:25.588000             🧑  作者: Mango

代码示例1
let picture =  ["abc", "ded"]; 

function addBorder(picture) {
 //adding the * on the top of the picture array as equal to the lenght of the top element of the array.
 let top = '*'.repeat(picture[0].length);
 picture.unshift(top);

 //looping through the array and concat the * at the end and the start of the array
 for(let i = 0; i < picture.length; i++){
     picture[i] = picture[i] + '*';
     picture[i] = '*' + picture[i];
 }

 //adding the * on the bottom of the picture array as equal to the lenght of the last element of the array.
 let bottom = '*'.repeat(picture[1].length);
 picture.push(bottom);
 
 return picture;
}