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)
Also in JavaScript:
- change form action js
- google gapi auth2 get current token
- check whether a checkbox is checked in jQuery
- gatsbyjs image sharp
- get local time second javascript heure temps réel
- how to update value in nested json using id in javascript
- canvas nodejs
- remove punctuation marks from string js
- javascript style an element
- can I pass function as prop on route change
- if condition in class angular 8
- 'App' is not defined react/jsx-no-undef
- referenceerror document is not defined node js
- javascript get cpu cores
- get object with max value javascript
- how to make 1st letter capital in ejs
- discord.js v12 how to set owner commands
- webpack react proxy not working
- how to use js console log
- sort function in react js
- function(global factory)
- arr.sort
- javascript function exercises
- filter biggest value javascript object