728x90

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;
}

+ Recent posts