http://bit.ly/2xU71ep


^ 일단 위에링크가 퀴즈의 힌트이다.


퀴즈: 

json 형태의 집안 family tree 가있다고 하자


const familyTree = {

  jason: {

    age: 31,

    education: 'highschool',

    next: {

      ggalggal: {

        age: 99,

        address: 'asfoasojf',

        sex: 'male',

        next: {

          ggalggalson: {

            age: 1,

            sex: 'female'

          }

        }

      },

      ggilggil: {

        age: 11

      }

    }

  }

}


물론 이것을 familyTree.jason.age 


이런식으로 접근해도되지만 저 data 는 언제 바뀔지모른다.


요구사항

1) family tree 의 각 사람의 properties 를 접근하는 코드를 작성하라. 이떄 next 는 그사람의 자식을 뜻한다.

2) 제일 효과적인 코드를 작성해야된다. 코드는 immutable data structure 를 지향해야된다.

3) 현 family tree 데이터의 각 사람은 next 라는 키워드를 통해 자식을 pointing 하지만 이게 next 가 나중에 뭐로 바뀔줄 모른다.

4) ramdajs 를 사용하고있으므로 ramda 의 모든 api 를 사용가능하다.

5) loopSequence() 의 3rd argument 인 flatten = true 를 넣으면

array 형태의 flatten 된 family tree 를 return 해야된다.

[ { name: "jason", ... }, { name: "ggilggil" ... } ]



example usage of "loopSequence"


1) loopSequence(console.log, familyTree)


....

{name: 'jason', age: 31, education: 'highschool'}

{name: 'ggalggal', age: 99, address: 'asfoasojf',  sex: 'male'}

{name: 'ggilggil', age: 11}

{name: 'ggalggalson',  age: 1, sex: 'female'}


'''


2) loopSequence(console.log, familyTree, true)


'''

[{name: 'jason', age: 31, education: 'highschool'},

{name: 'ggalggal', age: 99, address: 'asfoasojf',  sex: 'male'},

{name: 'ggilggil', age: 11},

{name: 'ggalggalson',  age: 1, sex: 'female'}]