function solution(today, terms, privacies) {
var answer = [];
const contract = (terms.map(str => str.match(/\d+/)[0]));
const todayDate = '2020.01.01';
let termsMap = new Map();
for (let str of terms) {
let [key, value] = str.split(' ');
termsMap.set(key, value);
//console.log(termsMap.get(key));
}
const [year, month, day] = today.split(".").map(Number);
const todayCount = ((year-2000) *12*28) + ((month-1)*28) + (day-1);
// 6720
const privaciesMap1 = privacies.map((map, idx) => [idx+1, ...map.split(' ')]);
//console.log(privaciesMap1);
for (let i = 0; i < privaciesMap1.length ; i++){
let value = privaciesMap1[i][2];
console.log(termsMap.get(value));
let [year, month, day] = privaciesMap1[i][1].split(".").map(Number); let diffCount = ((year-2000) *12*28) + ((month-1)*28) + (day-1);
if(todayCount >= (diffCount+(termsMap.get(value)*28))){
answer.push(privaciesMap1[i][0]);
}
}
return answer;
}
'IT > JavaScript' 카테고리의 다른 글
코딩테스트연습 - KAKAO BLIND (2) 효율성 0 (0) | 2023.01.26 |
---|---|
코딩테스트연습 > 2021 KAKAO BLIND RECRUITMENT 효율성 0 코드 ㅜㅜ (0) | 2023.01.26 |
간단한 카운터 프로그램 (0) | 2023.01.25 |
현재 위치를 알아내는 방법 (0) | 2022.12.16 |
백그라운드 이미지 랜덤하게 지정하기. (0) | 2022.11.17 |