Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

100
Views
Get dates from array and disable those dates from calendar that repeat more than twice

I want to get dates from array which are repeated 3 times so I can disable those dates from calendar.

function disbaleDate() {
  const arr = [
    "1/6/2022",
    "12/6/2022",
    "4/6/2022",
    "6/6/2022",
    "1/6/2022",
    "1/6/2022",
  ];
  const increment = [];


    for (let i = 1; i < arr.length; i++) {
      for (let j = 0; j < i; j++) {
        if (arr[j] === arr[i]) {
          increment.push(arr[i]);
        }
      }
    }
  
  console.log(increment);
}

disbaleDate();

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

function disableDate() {
    const arr = ["1/6/2022", "12/6/2022", "4/6/2022", "6/6/2022", "1/6/2022", "1/6/2022",];
       
    const backendData = ["12/12/2022", "12/6/2021", "14/6/2022", "16/6/2022", "1/6/2022", "11/6/2022",];
        
    const increment = [];

    if (backendData.length > 0) {
        for (let i = 0; i < backendData.length; i++) {
            if (arr.includes(backendData[i])) {
                increment.push(backendData[i]);
            }
        }
    }

    console.log(increment);
}
disableDate();
about 4 years ago · Juan Pablo Isaza Report

0

Ok, updating my answer


// reducer willproduce an object with the date as the key, and the amount repeated as the value
const countRepeated = arr.reduce((a, c) => {
    if (a[c]) {
        a[c] = a[c] + 1;
        return a;
    }
    
    a[c] = 1;
    return a;
}, {})

// will filter those whose values are greater than 2
return Object.keys(countRepeated).filter( date => date > 2)
about 4 years ago · Juan Pablo Isaza Report

0

const disable  = () => {

const arr = [
      "1/6/2022",
      "12/6/2022",
      "4/6/2022",
      "6/6/2022",
      "1/6/2022",
      "1/6/2022",
    ];
    let data =[];
    data = arr.filter((el, i) => i !== arr.indexOf(el) )
    let result = data.filter((el,i) => i ===data.indexOf(el))
    
   
    
 return  result;
    
}

console.log(disable())

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!