Smallest Common Multiple - last criteria

Ok, so the below code works for all test criteria but the last one, when I run the test on fcc, it fails the call to array points [23,18]. BUT…if I put my code into a jfiddle, the number matches actually to the expected test result. So how can my code work in a jsfiddle, but not fcc?? Here’s my code (and yes not elegant, but I’ve been on this challenge for a while and just wanted a working solution.)

function numRangeArray(start, end){
  var myArr = [];
  for(var i = start; i >= end; i--){
  return myArr;

function smallestCommons(arr) {
  if(arr[0] > arr[1]) {arr = numRangeArray(arr[0], arr[1]);}
  else {arr = numRangeArray(arr[1], arr[0]);}
  //arr is not sorted high to low with all numbers in range
  var smallestCommonMultiple = 0;
  var index= 1;
  while(smallestCommonMultiple === 0){
    var temp = arr[0] * index;
    var counter = 0;
    for(var j = 0; j < arr.length; j++){
    	if(temp % arr[j] === 0){
      } else if(temp % arr[j] !== 0){
     if(counter === arr.length){
     	smallestCommonMultiple = temp;
     } else {
    console.log("Smallest: " + smallestCommonMultiple);
  return smallestCommonMultiple;

I’ve edited your post for readability. When you enter a code block into the forum, remember to precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.


You had added three single quotes on the line before and line after the code, but you should have used three backticks.