# Steamroller solution giving right answer to other interpreter but not in free code camp

**URL:** <https://forum.freecodecamp.org/t/steamroller-solution-giving-right-answer-to-other-interpreter-but-not-in-free-code-camp/161047>\
**Category:** General\
**Created:** [November 27, 2017, 7:51am UTC](https://forum.freecodecamp.org/t/steamroller-solution-giving-right-answer-to-other-interpreter-but-not-in-free-code-camp/161047 "2017-11-27T07:51:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nirdesh27Kumar](https://avatars.discourse-cdn.com/v4/letter/n/cdc98d/32.png) [@nirdesh27Kumar](https://forum.freecodecamp.org/u/nirdesh27Kumar)\
**Post date:** [November 27, 2017, 7:51am UTC](https://forum.freecodecamp.org/t/steamroller-solution-giving-right-answer-to-other-interpreter-but-not-in-free-code-camp/161047/1 "2017-11-27T07:51:25Z")

</div>

```auto
var arrayValue=[];
var j=0;
function recursionIsFunny(arr){
  if(Array.isArray(arr)){
       // console.log("yes");
        var i=0;
        while(i<arr.length){
            ///steamrollArray(arr[i]);i++;
            recursionIsFunny(arr[i]);i++;
        }
        
    }else{
        arrayValue[j]=arr;j++;
    } 
  
}

function steamrollArray(arr) {
  // I'm a steamroller, baby
    //console.log("no");
   recursionIsFunny(arr);
   // console.log(arrayValue);
  return arrayValue;
}

steamrollArray([1, {}, [3, [[4]]]]);

```

---

<div class="post-metadata">

**Author:** ![kevcomedia](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/kevcomedia/32/125737_2.png) [@kevcomedia](https://forum.freecodecamp.org/u/kevcomedia)\
**Post date:** [November 27, 2017, 7:54am UTC](https://forum.freecodecamp.org/t/steamroller-solution-giving-right-answer-to-other-interpreter-but-not-in-free-code-camp/161047/2 "2017-11-27T07:54:32Z")

</div>

Solutions with global variables generally don’t pass in the challenges. You’ll have to rewrite your code so that there are no globals.

I’ve alse 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](http://forum.freecodecamp.com/t/forum-code-formatting/25574) to find the backtick on your keyboard. The “preformatted text” tool in the editor (`</>`) will also add backticks around text.

![markdown_Forums](https://sea3.discourse-cdn.com/freecodecamp/uploads/default/original/3X/4/b/4b9a26f0c243380dd84935f4e29b92e3ecee8d05.gif)

---

<div class="post-metadata">

**Author:** ![nirdesh27Kumar](https://avatars.discourse-cdn.com/v4/letter/n/cdc98d/32.png) [@nirdesh27Kumar](https://forum.freecodecamp.org/u/nirdesh27Kumar)\
**Post date:** [November 27, 2017, 9:57am UTC](https://forum.freecodecamp.org/t/steamroller-solution-giving-right-answer-to-other-interpreter-but-not-in-free-code-camp/161047/3 "2017-11-27T09:57:22Z")

</div>

thanks cat 😉 …it works

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 17, 2021, 8:33pm UTC](https://forum.freecodecamp.org/t/steamroller-solution-giving-right-answer-to-other-interpreter-but-not-in-free-code-camp/161047/4 "2021-01-17T20:33:49Z")

</div>

Closed on January 17, 2021, 8:33pm UTC


