freeCodeCamp Challenge Guide: Steamroller problem

Tell us what’s happening:

freeCodeCamp Challenge Guide: Steamroller

I am getting correct output but still it is not accepting it.

This has happened to me before. I don’t like using hints often but for problems like these I am forced to use the hints :frowning: .

Can anyone help me with a solution to this glitch or mistake in my program?

Your code so far

function steamrollArray(arr) {
  return arrayrec(arr);

const sol=[]; 
  function arrayrec(arr){
    for(let i in arr){
      if(JSON.stringify(arr[i]) == '{}'){
      if(typeof arr[i] != "object")

    return sol;

var a= steamrollArray([1, {}, [3, [[4]]]]); 
for(var i in a){
console.log(typeof a[i]);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36.

Challenge: Steamroller

Link to the challenge:

Your code contains global variables that are changed each time the function is run. This means that after each test completes, subsequent tests start with the previous value. To fix this, make sure your function doesn’t change any global variables, and declare/assign variables within the function if they need to be changed.


var myGlobal = [1];
function returnGlobal(arg) {
  return myGlobal;
} // unreliable - array gets longer each time the function is run

function returnLocal(arg) {
  var myLocal = [1];
  return myLocal;
} // reliable - always returns an array of length 2
1 Like

Really an amazing challenge.

1 Like