#대/소문자 맞게 수정하기
var list = document.querySelector('.output ul');
list.innerHTML = '';
var cities = ['lonDon', 'ManCHESTer', 'BiRmiNGHAM', 'liVERpoOL'];
for(var i = 0; i < cities.length; i++) {
var input = cities[i];
var lower = input.toLowerCase(); // input전체 소문자로
var firstLetter = lower.slice(0,1); //소문자된 배열이 첫문자 잘라서 저장
var capitalized = lower.replace(firstLetter, firstLetter.toUpperCase());
// firstLetter에 저장된 문자를 대문자로 변환
var result = capitalized; // 결과에 담기
var listItem = document.createElement('li');
listItem.textContent = result;
list.appendChild(listItem);
}
#인사말 필터링하기
var list = document.querySelector('.output ul');
list.innerHTML = '';
var greetings = ['Happy Birthday!',
'Merry Christmas my love',
'A happy Christmas to all the family',
'You\'re all I want for Christmas',
'Get well soon'];
for (var i = 0; i < greetings.length; i++) {
var input = greetings[i];
// Your conditional test needs to go inside the parentheses
if(greetings[i].indexOf('Christmas') !== -1)
// in the line below, replacing what's currently there
if (greetings[i]) {
var result = input;
var listItem = document.createElement('li');
listItem.textContent = result;
list.appendChild(listItem);
}
}
#making new strings from old parts
var list = document.querySelector('.output ul');
list.innerHTML = '';
var stations = ['MAN675847583748sjt567654;Manchester Piccadilly',
'GNF576746573fhdg4737dh4;Greenfield',
'LIV5hg65hd737456236dch46dg4;Liverpool Lime Street',
'SYB4f65hf75f736463;Stalybridge',
'HUD5767ghtyfyr4536dh45dg45dg3;Huddersfield'];
for (var i = 0; i < stations.length; i++) {
var input = stations[i];
// write your code just below here
var code = input.slice(0,3);
var semiC = input.indexOf(';');
var name = input.slice(semiC+1);
var final = code + ": " + name;
var result = final;
var listItem = document.createElement('li');
listItem.textContent = result;
list.appendChild(listItem);
}
'TIL' 카테고리의 다른 글
Mozilla - javascript first steps (0) | 2019.11.05 |
---|---|
Mozilla - array (0) | 2019.11.04 |
TIL D-85 CRUD/index, new, create (0) | 2019.11.04 |
TIL D-86 mongoDB atlas, .gitignore, .env (0) | 2019.11.03 |
TIL D-90 구독과 좋아요의 경제학, 구독모델 (0) | 2019.10.30 |
댓글