This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function countAllCharacters(str) { | |
let obj = {}; | |
for(let i = 0; i < str.length; i++){ | |
if (obj[str[i]] === undefined) { | |
obj[str[i]] = 0 | |
} | |
obj[str[i]]++ | |
} | |
return obj; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function countAllLetters(str) { | |
let obj = {}; // 변수에 빈 객체 할당 | |
for(let i = 0; i < str.length; i++){ // 반복문을 통해 인자로 받은 문자열 순회 | |
if (obj[str[i]] === undefined) { // i번째 문자가 기존 객체의 키로 존재하지 않으면 | |
obj[str[i]] = 0 // i번째 문자와 0을 새로운 키값으로 생성 | |
} | |
obj[str[i]]++ // 해당 문자가 반복될 때 마다 1씩 값을 추가한다. | |
} | |
return obj; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 문자열을 입력받아 문자열을 구성하는 각 문자를 키로 갖는 객체를 리턴 | |
let output = countAllLetters('apple'); | |
console.log(output); // --> {a: 1, p: 2, l: 1, e: 1} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let score; // 변수 선언(변수 선언문) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log(score); // undefined | |
var core; // 변수 선언문 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
consol.log(a); // undefined | |
let a = 100; | |
console.log(a); // 100 | |
} | |
foo(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let socore; // 변수 선언 | |
score = 80; // 값의 할당 | |
let score = 80; // 변수 선언과 값의 할당 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log(score); // undefined | |
let core; // 변수 선언 | |
score = 80; // 값의 할당 | |
console.log(score); // 80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let score = 80; // 변수 선언과 값의 할당 | |
score = 90; // 값의 재할당 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 카멜 케이스(camelCase) | |
let firstName; | |
// 스케이크 케이스(snake_case) | |
let firt_name; | |
// 파스칼 케이스(PascalCase) | |
let FirstName; | |
// 헝가리언 케이스(typeHungarianCase) |
OlderNewer