Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions STEP2-2/STEP2_2.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
let utils = require("./STEP2_2_utils")
let log = "<계산수행순서 > \n";
let result = 0;
let logList = ["<계산 수행 순서> \n"];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

데이터를 보관할때는 순수한 데이터를 보관하는 것이 좋아요.
그래야 데이터를 다양하게 활용할 수가 있겠죠.
그래서 loglist가 출력순서를 저장한다고 하여도, 출력용 메시지를 담는 건 좋지 않아보이네요.



let getArea = (func_name, ...args) => {
switch (func_name){
Expand All @@ -17,16 +18,22 @@ let getArea = (func_name, ...args) => {
result = utils.polygon.cylinder(...args);
break;
}
log += `${func_name} : ${result} \n`;
addLog(func_name, result);
};

let printExecutionSequence = () => {
console.log(log.substr(0, log.length - 2))
let addLog = (func_name, result) => {
logList.push(`${func_name} : ${result}`)
}

let printExecutionSequence = (logList) => {
logList.forEach(element => {
console.log(element);
});
}

getArea('circle', 3)
getArea('circle', 1, 3);
getArea('rect', 10, 15);
getArea('trapezoid', 10, 15, 12);
getArea('cylinder', 3, 7);
printExecutionSequence();
printExecutionSequence(logList);