Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(args) {
- let maxProduct = Number.NEGATIVE_INFINITY;
- const arrOfNumbers = args.map(Number);
- arrOfNumbers.forEach((el, i) => {
- if (el >= 0 && el <= 9 && i + el < arrOfNumbers.length) {
- let product = 1;
- for (let j = i + 1; j <= i + el; j++) product *= arrOfNumbers[j];
- if (product > maxProduct) {
- maxProduct = product;
- }
- }
- });
- console.log(maxProduct);
- }
Add Comment
Please, Sign In to add comment