Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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)
Comment

PREVIOUS NEXT
Code Example
Javascript :: js fill array with count elements 
Javascript :: reduce javascript acc became numeber insted array 
Javascript :: how to securely post form data to api vuejs 
Javascript :: difference between Redis and StrictRedis 
Javascript :: solr regex expression 
Javascript :: create a vue project from scratch with 2.9.6 
Javascript :: multi auth passport stackoverflow 
Javascript :: preventive vs reactive 
Javascript :: passing a variable to the width style div angular 
Javascript :: get the latest git commit SHA-1 in a repository js 
Javascript :: como hacer un onpress en react native expo 
Javascript :: capturar el id de un elemento con jquery 
Javascript :: how to add functionality inside js object 
Javascript :: Node Locking 
Javascript :: survey js go to last page 
Javascript :: jquery call for Elementor 
Javascript :: js event problem solving 
Javascript :: c++ 2d rectangle collision 
Javascript :: pwa tabs chrome extension 
Javascript :: form to object function 
Javascript :: cdate ssrs expressions 
Javascript :: sinon chaining method 
Javascript :: signalwire instaall in node 
Javascript :: convert from python to javascript online 
Javascript :: instafeeed.js pulls back unknown for image file 
Javascript :: $("#heading").offset({ left: left Offset }); 
Javascript :: tableexport dates 
Javascript :: how to see the defenition of a function inside browser console 
Javascript :: how to get selected option attribute value in jquery 
Javascript :: The Works of Archimedes 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =