These are chat archives for FreeCodeCamp/HelpJavaScript

5th
May 2018
JJ Megma
@megma_jj_twitter
May 05 2018 19:23
@NikolaNbgd what is this data?
[
 "content": "dummy data",
  "content 2":  [
    "dummy": "dummy1",
  "dummy3": "dummy4",
]
I think you are missing {}
among several other errors
JJ Megma
@megma_jj_twitter
May 05 2018 19:37
@NikolaNbgd I think you are looking to do something like this? Its definitly not the best way to go about it but its the most explicit way that will help you understand I do believe.
let data = {
  "content 2":[
    {
    "dummy": "dummy1",
    "dummy3": "dummy4",
    }
  ]
}

function displayData(obj){
    for(var key in obj){
      if(key === "content 2"){
        for(var i = 0; i<obj[key].length; i++){
          console.log(obj[key][i].dummy)
        }
      }
    }
}
displayData(data)
I hope that this helps and I understood your question right.
:)
Ryan Williams
@Ryanwfile
May 05 2018 20:38
I am working on the steamroller algorithm and it feels like a great place to try a recursive function but I'm not getting the exact results I'm looking for, the final array should have 0 arrays in it. Any help is greatly appreciated.
steamrollArr = arr =>{  
  let flatten = arr.reduce((accumulator, currentValue) => accumulator.concat(currentValue),[]);
  flatten.map(idx = idx => {
    if (Array.isArray(idx)){
      return steamrollArr(idx);
    }
  }) 
  return flatten;
}
console.log(steamrollArr([1, [2], [3, [[4]]]]));//currently this logs [1,2,3,[[4]]]
Gulsvi
@gulsvi
May 05 2018 20:51
@Ryanwfile with that approach, you'll need to use helper method recursion to track the state of your final array. You can use a pure recursion approach as you're attempting, however, with .find() instead of .map()
Ryan Williams
@Ryanwfile
May 05 2018 20:55
@gulsvi Thank you I will try that, forgot about find()
CamperBot
@camperbot
May 05 2018 20:55
:star2: 2713 | @gulsvi |http://www.freecodecamp.org/gulsvi
ryanwfile sends brownie points to @gulsvi :sparkles: :thumbsup: :sparkles:
Ryan Williams
@Ryanwfile
May 05 2018 23:40
@gulsvi I got it to work with the find method, thank you so much for the help
CamperBot
@camperbot
May 05 2018 23:40
ryanwfile sends brownie points to @gulsvi :sparkles: :thumbsup: :sparkles:
:star2: 2714 | @gulsvi |http://www.freecodecamp.org/gulsvi
Conor Murphy
@cmurphy580
May 05 2018 23:44
can anyone help me with a compiling issue?
and i'm assuming a package.json issue
Stephen James
@sjames1958gm
May 05 2018 23:45
@cmurphy580 What is the issue