본문 바로가기

전체 글267

[프로그래머스] 체육복 (javascript) Javascript 프로그래머스 솔루션 function solution(n, lost, reserve) { let realLost = lost.filter(a => !reserve.includes(a)); let realReserve = reserve.filter(a => !lost.includes(a)); return n - realLost.filter(a => { let b = realReserve.find(r => Math.abs(r-a) r !== b); }).length; } 출처: jsikim1.tistory.com/52 1. what is "filter" in js? filter() The filter() method creates a new array with all elements tha.. 2021. 1. 23.
[프로그래머스] 체육복 (python) Python 주의사항은 여벌을 가지고 있는 리스트에서도 도난이 발생할 수 있기 때문에 lost와 reserve 각각에 대해서 중복이 없게 차집합을 만들어 놓아야 한다. (first two lines of codes.) 그리고 여벌 리스트(rsv_pos)를 loop돌면서 도난 당한 리스트(lost_pos)의 앞 or 뒤에 여벌리스트의 요소들이 있는지 체크하면서 도난 리스트를 제거한다. python remove method는 list에서 remove에 주어진 item을 찾아서 삭제하는 메서드이다. 만약, 해당 아이템이 없다면 "ValueError: list.remove(x): x not in list" 이러한 에러 메시지를 보게될 것이다. def solution(n, lost, reserve): rsv_po.. 2021. 1. 18.
[Javascript] var, let, const var, let, const *hoisting? gmlwjd9405.github.io/2019/04/22/javascript-hoisting.html yuddomack.tistory.com/entry/%EC%9E%90%EB%B0%94%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8-%ED%98%B8%EC%9D%B4%EC%8A%A4%ED%8C%85Hoisting var, let, const gist.github.com/LeoHeo/7c2a2a6dbcf80becaaa1e61e90091e5d happycording.tistory.com/entry/let-const-%EB%9E%80-%EC%99%9C-%EC%8D%A8%EC%95%BC%EB%A7%8C-%ED%95%98%EB%8A%94%EA%B0%.. 2021. 1. 18.
[프로그래머스] 모의고사 (python, javascript) 출처: wooaoe.tistory.com/65 def solution(answers): answer = [] answer_temp = [] count01 = 0 count02 = 0 count03 = 0 one = [1,2,3,4,5] two = [2,1,2,3,2,4,2,5] three = [3,3,1,1,2,2,4,4,5,5] for i in range(len(answers)): if answers[i] == one[i%len(one)]: count01+=1 if answers[i] == two[i%len(two)]: count02+=1 if answers[i] == three[i%len(three)]: count03+=1 answer_temp = [count01, count02, count03] f.. 2021. 1. 17.
Advanced Javascript and DOM Manipulation - Drum kit addEventListener() The EventTarget method addEventListener() sets up a function that will be called whenever the specified event is delivered to the target. Common targets are Element, Document, and Window, but the target may be any object that supports events (such as XMLHttpRequest). addEventListener() works by adding a function or an object that implements EventListener to the list of event l.. 2021. 1. 6.
Dicee var randomNumber1 = Math.floor(Math.random() * 6) + 1; var randomImageSource = "images/dice" + randomNumber1 + ".png"; var image1 = document.querySelectorAll("img")[0] var image2 = document.querySelectorAll("img")[1] image1.setAttribute("src", randomImageSource) // Image 1 var randomNumber1 = Math.floor(Math.random() * 6) + 1; var randomImageSource = "images/dice" + randomNumber1 + ".png"; var i.. 2021. 1. 5.
The Document Object Model (DOM) Inline, Internal, and External JS Inline JS By applying inline js, a problem occurs about quotation marks. To fix this, we have to use different quotation marks that are single and double. Like this. * Recommend: Avoid inline JS, Like CSS. Internal JS External JS Unlike css, js script needs to be inside of body tag. If the css link located at the below js link, then alert pops up and show css st.. 2021. 1. 3.
Intermediate Javascript Comparator and Equality Three equal signs ("===") is also checking the datatypes are matching.(more strict) Two equal signs doesn't care about the data types. && : AND II : OR function bmiCalculator (weight, height) { var interpretation =weight/(height*height); if(interpretation=18.5)&&(interpretation24.9){ return("Your BMI is "+ interpretation+", so you are overweight."); } } Finish a line with.. 2021. 1. 2.
Intermediate CSS - PART III (Refactoring II, Selector Priority) Refactoring Give colored-section to each section And remove css with the same stylings. Selector Priority inline styles are more specific than internal or external CSS styles. As you can see, inline style overrides external CSS. h1 element VS. class VS. Id Id style overrides all the other styles. Even though I changed the order of class and id, id style overrides all since it's more specific. Ti.. 2020. 12. 27.