From c5d37164f0dfb17d56aea8b69ed965001e25294f Mon Sep 17 00:00:00 2001 From: Jason Fu Date: Fri, 16 Sep 2022 14:48:23 -0700 Subject: [PATCH 1/2] homework file created --- box_it_script/box_it_script.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 box_it_script/box_it_script.js diff --git a/box_it_script/box_it_script.js b/box_it_script/box_it_script.js new file mode 100644 index 0000000..e69de29 From 5f2e3d3f1105b1fe3a5b65badde7ab1266ec08b2 Mon Sep 17 00:00:00 2001 From: Jason Fu Date: Thu, 22 Sep 2022 23:30:02 -0700 Subject: [PATCH 2/2] homework 1 commited --- box_it_script/box_it_script.js | 90 ++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/box_it_script/box_it_script.js b/box_it_script/box_it_script.js index e69de29..a1b69ea 100644 --- a/box_it_script/box_it_script.js +++ b/box_it_script/box_it_script.js @@ -0,0 +1,90 @@ +const input = process.argv.splice(2, process.argv.length - 1) + +// ┏ ━ ┓ +// ┃ ┃ +// ┣ ━ ┫ +// ┃ ┃ +// ┗ ━ ┛ + + //---find longest Word length from the array +let longestWord = 0 +for(let element of input){ + if(element.length > longestWord){ + longestWord = element.length + } +} +let lineNumber = longestWord + +// //------------------DrawLine Function + +let strightLine = "━" +// console.log(strightLine) + +function drawLine(lineNumber){ + return strightLine.repeat(lineNumber) +} +drawLine(4) + +// //-------------------drawTopBorder Function +let topLeftCorner = "┏" +let topRightCorner = "┓" +function drawTopBorder(lineNumber){ + return topLeftCorner + drawLine(lineNumber) + topRightCorner +} +drawTopBorder(4) + +// //-----------------drawMiddleBorder Function + +let middleLeftCorner = "┣" +let middleRightCorner = "┫" +function drawMiddleBorder(lineNumber){ + return middleLeftCorner + drawLine(lineNumber) + middleRightCorner + } +drawMiddleBorder(4) + +// //-----------------drawBottomBorder Function + +let bottomLeftCorner = "┗" +let bottomRightCorner = "┛" +function drawBottomBorder(lineNumber){ + return bottomLeftCorner + drawLine(lineNumber) + bottomRightCorner + } +drawBottomBorder(4) + +// //---------------- boxIt Function + +function boxIt (input){ + let middlePart = "" + let speceOnRight = "" + let firstLine = "" + let firstword = input[0] + + if(input[0]!==undefined){ + speceOnRight = ' '.repeat(lineNumber - input[0].length) + firstLine = "\n" + "┃" + firstword + speceOnRight + "┃" + } + + for(let i = 1; i 200); + +// // // $ node boxit.js 'Jon Snow' 'Cersei Lannister' 'Daenerys Targaryen' +// // // $ node boxit.js 'Jon Snow' +// // // $ node boxit.js \ No newline at end of file