Skip to content
Merged
Show file tree
Hide file tree
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
14 changes: 14 additions & 0 deletions sik9252/JadenCase_문자열_만들기.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
function capitalize(str) {
return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

항상 함수 분리를 깔끔하게 잘 하시는 군용!


function solution(s) {
var answer = "";
let word = [];

s = s.split(" ");
s.map((e) => word.push(capitalize(e)));
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

map을 쓰셔서 뭔가 리턴하시려나보다 생각해서 변수를 빠뜨렷나 싶었어요ㅠ
forEach를 사용하면 오해가 없어질 것 같아요ㅎ

answer = [...word].join(",").replaceAll(",", " ");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

join에서 바로 (" ") 요거는 안되는 건가요?!


return answer;
}
16 changes: 16 additions & 0 deletions sik9252/올바른_괄호.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
function solution(s) {
var answer = true;
const stack = [];

for (let i = 0; i < s.length; i++) {
if (stack.length === 0 || s[i] === "(") {
stack.push(s[i]);
} else {
stack.pop();
}
}
Comment on lines +5 to +11
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

")"가 먼저 채워지는 조건에서는 얼리 리턴으로 처리해주면 좋을 것 같아요!


answer = stack.length === 0 ? true : false;

return answer;
}
9 changes: 9 additions & 0 deletions sik9252/최댓값과_최솟값.js
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

깔끔하군요!

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function solution(s) {
var answer = "";

let arr = s.split(" ");
arr = arr.sort((a, b) => Number(a) - Number(b));
answer = arr[0] + " " + arr[arr.length - 1];

return answer;
}
Loading