birthday

    0

    0

    This line creates a function called birthday. The first parameter is the string "birthday", the second is the number "d" (days since February 29th), and the third is the number "m" (months since January 1st). The function takes three parameters. The first is the string "birthday", the second is the number "d" (days since February 29th), and the third is the number "m" (months since January 1st). The function will take every day from "d" days ago up to and including the current day, and will return the number of days in this time period.

    function birthday(s, d, m) {
      let count=0;
      for(let i=0;i<s.length;i++){
        let a=s.slice(i,i+m).reduce((a,b)=> a+b);
        if(a===d){
          count++;
        }
      }
      return(count)
    
    }
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.