Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSS

Add border to the array

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;
}

Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Add #border #array
ADD COMMENT
Topic
Name
4+3 =