Answers for "using slice and reduce together in javascript"

0

using slice and reduce together in javascript

//subdivision Array
function birthday(s, d, m) {
    let count = 0
    const length = s.length - m 
    for(let i=0;i<=length;i++) {
        if(s.slice(i,i+m).reduce((a,b) => a+b)=== d) {
            count++
        }
    }
    console.log(count)
}
birthday([1,2,1,3,2],3,2)
Posted by: Guest on January-16-2021

Code answers related to "using slice and reduce together in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language