Advertisement
braveheart1989

my solution 1

Oct 16th, 2016
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(input) {
  2.     let result = input.map(Number);
  3.     let currentNum = 0;
  4.     let multi = 1;
  5.     let arr = [];
  6.     let variable = 1;
  7.     let isMulty = false;
  8.     for (let i = 0; i < result.length; i++) {
  9.         if (result[i] <= 9 && result[i] > -1) {
  10.  
  11.             for (let j = 1; j <= result[i]; j++) {
  12.  
  13.                 variable *= result[j + i];
  14.                
  15.                 isMulty = true;
  16.             }
  17.             if (!isNaN(variable)) {
  18.                 arr.push(variable);
  19.             }
  20.             variable=1;
  21.         }
  22.     }
  23.     if (isMulty) {
  24.         let max = Math.max.apply(Math, arr);
  25.         console.log(max);
  26.     }
  27.     else {
  28.         console.log(0);
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement