개발 일기
[Javascript] 힘내자 진짜...
metdoyo
2022. 10. 7. 22:16
힘내자...
개힘들지만 그래도 공부는 계속해야 해...
오늘은 grammar checker를 마쳐야 한다구...
더 이상 질질 끌면 절대 안 돼
나중에 자바스크립트 딥다이브 사서 봐야지...
책을 샀는데 이해를 못 하면 안 되잖아...
우씨ㅠ 이거 듣고 노마드 강의 바로 들을까
점점 처지고 재미도 없는 기분인디...
클론코딩이 훨 재밌을 것 같다ㅇㅅㅇ
let story = 'Last weekend, I took literally the most beautifull bike ride of my life. The route is called "The 9W to Nyack" and it stretches all the way from Riverside Park in Manhattan to South Nyack, New Jersey. It\'s really an adventure from beginning to end! It is a 48 mile loop and it literally took me an entire day. I stopped at Riverbank State Park to take some artsy photos. It was a short stop, though, because I had a freaking long way to go. After a quick photo op at the very popular Little Red Lighthouse I began my trek across the George Washington Bridge into New Jersey. The GW is a breathtaking 4,760 feet long! I was already very tired by the time I got to the other side. An hour later, I reached Greenbrook Nature Sanctuary, an extremely beautifull park along the coast of the Hudson. Something that was very surprising to me was that near the end of the route you literally cross back into New York! At this point, you are very close to the end.';
let storyWords = story.split(' '); // 스페이스로 문장을 구분하여 ''안에 표기해 줌
let unnecessaryWord = 'literally';
let misspelledWord = 'beautifull';
let badWord = 'freaking';
let count = 0
storyWords.forEach((word) => {
word = story[count];
count++;
}) // 단어를 하나씩 돌려 주는 foreach 문
console.log(count)
storyWords = storyWords.filter(word => { // 여기서 약간 삽질을 했습니다
return word !== unnecessaryWord
}) // 여기 return을 쓰라는데 왜 return을 써야 하는 거지?
storyWords = storyWords.map((word) => {
if(word === misspelledWord) {
word = 'beautiful';
return word
} else {
return word
}
})
console.log(storyWords.findIndex(word => {
return word === 'freaking';
}))
storyWords[78] = 'really';
let lengthCheck = storyWords.every((word) => {
return word.length < 10;
}) // 변수를 선언해서 콘솔에 log해 주면 되는구나!
console.log(lengthCheck);
let FindLongWord = storyWords.findIndex(word => word.length > 10)
console.log(FindLongWord)
storyWords[111] = 'stunning';
console.log(storyWords.join(' ')); // 다시 스페이스를 붙여서 합침
근데 막상 코드 짜기 시작하니까 존잼
집중해서 한 번에 다 짰다ㅋㅋㅋㅋㅋ
iterator 문법은 검색해 가면서 하긴 했지만...
배웠던 것은 코멘트로 코드 안에 달아 놨으니 부디 미래의 내가 다시 보고 느끼는 점이 있기를 바랄 뿐이다...
빨리빨리 object로 넘어가야지!
아맞다 iterator 안에 있는 callback function에 왜 return이 들어가야 하는지 찾아봐야 한다
이건 다른 글로 써야지