항상 강의를 들으면서
기초를 알려주고 예시에 적용하려고 할 때
예시의 코드는 보지 않고 어떻게 구상할 것인지 내용만 듣고
스스로 코드를 작성해보는 방법.
기억에 남는데 큰 도움이 되는 것 같다.
배웠던 것을 즉시 다시 사용해보고 잠시 뒤, 1주일 뒤, 1달 뒤
이런식으로 복습하면 완전히 기억에 남는 훈련법이라고 한다.
출퇴근 경로를 이용해서 최대한 notion에 필기한 것들을 복습하자.
10시 45분 ~ 11시 30분 // 118강
11시 40분 ~ 1시 // 119강 코딩챌린지
1시 20분 ~ 2시 // 120강
저녁 121, 122, 123 코딩챌린지
언제 객체, 배열, set, map을 사용하는지
이것들을 총 이용한 코드챌린지 3번째
문자열을 이용해서 할 수 있는 작업 강의 3개.
그리고 이 문자열들을 다루는 메소드를 이용한 코드챌린지 4번째.
정답을 보지 않고 풀어서 기쁘다. :)
생각을 그대로 코드로 옮겼을 때 희열을 느낀다. 너무 재밌다.
'use strict';
/*
Write a program that receives a list of variable names written in underscore_case and convert them to camelCase.
The input will come from a textarea inserted into the DOM (see code below), and conversion will happen when the button is pressed.
THIS TEST DATA (pasted to textarea)
underscore_case
first_name
Some_Variable
calculate_AGE
delayed_departure
SHOULD PRODUCE THIS OUTPUT (5 separate console.log outputs)
underscoreCase ✅
firstName ✅✅
someVariable ✅✅✅
calculateAge ✅✅✅✅
delayedDeparture ✅✅✅✅✅
HINT 1: Remember which character defines a new line in the textarea 😉
HINT 2: The solution only needs to work for a variable made out of 2 words, like a_b
HINT 3: Start without worrying about the ✅. Tackle that only after you have the variable name conversion working 😉
HINT 4: This challenge is difficult on purpose, so start watching the solution in case you're stuck. Then pause and continue!
Afterwards, test with your own test data!
GOOD LUCK 😀
*/
// 스스로 도전
// 이 두 줄은 정답을 보고 도움을 받음.
document.body.append(document.createElement('textarea'));
document.body.append(document.createElement('button'));
// 스스로 구상. addeventlistner 은 구글 검색해서 다시 기억되살림. 대성공.
document.body.querySelector('button').addEventListener('click', function() {
const text = document.body.querySelector('textarea').value;
const textLower = text.toLowerCase();
const textSplit = textLower.split('\n');
let check = '✅';
for(const value of textSplit) {
const finalText = value.split('_');
const finalTextUpper = finalText[1].slice(0, 1).toUpperCase();
const final = finalText[0] + finalTextUpper + finalText[1].slice(1);
const final2 = final.replaceAll(' ', '');
console.log(final2.padEnd(20, ' ') + check);
check += '✅';
}
})
댓글