how do i solve using javascript Write a function called lucky_sevens which takes an array of integers and returns true if any three consecutive elements sum to 7. code example
Example: Write a function called lucky_sevens which takes an array of integers and returns true if any three consecutive elements sum to 7. by js
function luckySevens(arr){
for (let i = 0; i< arr.length; i++){
if (arr.slice(i,i+2).reduce((a,c)=>a+c) === 7) return true
else if (arr.slice(i,i+3).reduce((a,c)=>a+c) === 7) return true
}
return false
}