전체 글41 2023-05-16 javascript_array let voteCounter = {}; /*let i=0; let j=0;*/ for (let name of votes) { /*if(name==='이재식'){ voteCounter[name]=++i; }else{ voteCounter[name]=++j; }*/ if(name in voteCounter){ voteCounter[name]=voteCounter[name]+1; }else{ voteCounter[name]=1; } } We don't have to define variable i and j, if we use the second codes not the first codes. 2023. 5. 16. 2023-05-13 javascript //delete first element in array members.shift(); //delete last element in array members.pop(); //add element as first element of array members.unshift('Hello'); //add element as last element of array members.push('Bye'); brands.indexOf('Kakao'); Find 'Kakao' in array. If the array has it, then the array returns the index of it. If not, the array returns -1. Moreover, if the array has same multip.. 2023. 5. 13. 2023-05-11 javascript members=[ 'kim', 'choi', 'park' ]; members.splice(1,2); We delete elements of array using splice method. We first put the starting index as a first parameter, and the number of element that we want to delete as a second parameter. Meanwhile, the meaning of splice(1,2) is delete 2 elements from starting index 1. Therefore, only 'kim' will remain after the splice method is executed. members.splice.. 2023. 5. 11. 2023-05-08 javascript let before=1, after=1, sum=0; for (let i=1;i 2023. 5. 8. 2023-05-07 javascript When we define funtion, if we do not write 'return statement', then function returns 'undefined' value. We can assign some values to parameters. function introduce(name, age, nationality='South Korea'){ } We call these parameters as optional parameters. Optional parameters should be defined last like the example. We should define constant variable like this const MY_NUM = 1; We can select same c.. 2023. 5. 7. 2021/12/16 C언어 메모(백준) 백슬래시 출력 방법 : 출력하고자 하는 백슬래시 앞에 백슬래시를 붙인다. 쌍따옴표와 따옴표의 경우에도 마찬가지로 앞에 백슬래시를 붙여준다. 형 변환 방법 : 변수나 값 앞에 변환할 자료형을 붙인 뒤 ( ) (괄호)로 묶어주기. 예) num3 = (float)num1 / num2; double 자료형은 기본적으로 소수점 아래 6자리까지 출력한다. 시간을 앞설 때 12시 10분의 45분 전이라면 10+60-45와 같은 방식으로 계산해준다. 2021. 12. 16. 이전 1 2 3 4 5 6 7 다음