Es6 code failure - works correctly in chrome dev tools

Tell us what’s happening:
Hey! This is my first post here :smiley: I am currently on the Front End - Intermediate Algorithms section. I have just finished the “Smallest Common Multiple” assignment.

And while my code runs in Chrom Dev Tools terminal and produces the correct results for all test cases. In the freeCodeCamp terminal, it fails the last 2 cases.

I suspect it is because I am using es6 things… I am not really sure what to do about the warnings it gives in the code editor.

Is there any way to pass this assignment without rewriting my code?
Thank you!

Your code so far

//   (inclusive) in the given array
function rangeAndProducts(arr) {
  const minProd = arr[0] * arr[1];
  let maxProd = 1;
  const minRange = Math.min(...arr);
  const maxRange = Math.max(...arr);
  let range = Array.from(Array((maxRange + 1) - minRange).keys());
  range = range.map(val => val + minRange); // an array of the range
  for (let i = minRange; i <= maxRange; i += 1) {
    maxProd *= i;
  }
  return [range, minRange, minProd, maxProd];
}
function smallestCommons(arr) {
  const [range, minRange, minProd, maxProd] = rangeAndProducts(arr);
  let trigger = 0;
  let triggerArr = [];
  let testProd = minProd - minRange;
  // loop through each potential product
  let j = 0; // no infinty loops
  while (!trigger && j <= maxProd) {
    j += 1;
    testProd += minRange; // increment by the smallest number in the range
    for (let i = 0; i < range.length; i += 1) {
      const divided = testProd / range[i];
      if (testProd % range[i] === 0) {
        // test testProd is divisible by the current number in the range
        triggerArr[i] = 1; 
      } else {
        // test product not divisible by the current number in the range
        triggerArr[i] = 0; 
        break;
      }
    }
    // if even one number in the range is not divisible, loop again
    trigger = triggerArr.reduce((acc, curr) => acc * curr, 1);
    triggerArr = [];
  }
  return testProd;
}```
**Your browser information:**

Your Browser User Agent is: ```Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36```.

**Link to the challenge:**
https://www.freecodecamp.org/challenges/smallest-common-multiple

I see… carl-parrish already solved this…

I just found out that if I add
/*jshint esversion: 6 */
To the top of my code then I’m able to use ES6 for my solutions.

1 Like

Yeah, for some reason it doesn’t like ES6 by default.