Extracting data in ES6











up vote
1
down vote

favorite












I have this array const idArray = ["12", "231", "73", "4"] and an object



const blueprints = {
12: {color: red, views: [{name: "front}, {name: "back}, {name: "top}, {name: "bottom}]},
231: {color: white, views: [{name: "front}, {name: "back}]},
73: {color: black, views: [{name: "front}, {name: "back}, {name: "top}, {name: "bottom}]},
4: {color: silver, views: [{name: "front}, {name: "back}, {name: "top}, {name: "bottom}]},
}


How can I return an array of the following objects that have all front, back, top, and bottom using ES6 map/filter/some and etc?:



result =[
{colorId: "12", views: [{name: "front}, {name: "back}, {name: "top}, {name: "bottom}]}
{colorId: "73", views: [{name: "front}, {name: "back}, {name: "top}, {name: "bottom}]}
{colorId: "4", views: [{name: "front}, {name: "back}, {name: "top}, {name: "bottom}]}
]


I did it here but I feel like it is too messy and hard to read. Anybody could recommend on how to shorten it and make it easier to read using the ES6 functions (map, filter ...)?



 const result = idArray.map(id => {
const bluePrint = bluePrints[id];
const exists = blurPrint.views.some(view => view.name === 'top' || view.name === 'bottom');

if (exists) {
return {
colorId: id,
views: bluePrint.views
}
}
}).filter(bluePrint => !bluePrint);









share|improve this question


















  • 2




    Questions on how to optimize working code are better suited to be asked on codereview.stackexchange.com . You could use one reduce() instead of chaining map() and filter()
    – charlietfl
    Nov 15 at 18:05










  • You have lots of missing quotes in your original array and desired result.
    – Barmar
    Nov 15 at 18:14










  • Another typo: blurPrint should be bluePrint
    – Barmar
    Nov 15 at 18:19










  • bluePrint => !bluePrint should be bluePrint => bluePrint, otherwise you'll just get an array of undefined.
    – Barmar
    Nov 15 at 18:20

















up vote
1
down vote

favorite












I have this array const idArray = ["12", "231", "73", "4"] and an object



const blueprints = {
12: {color: red, views: [{name: "front}, {name: "back}, {name: "top}, {name: "bottom}]},
231: {color: white, views: [{name: "front}, {name: "back}]},
73: {color: black, views: [{name: "front}, {name: "back}, {name: "top}, {name: "bottom}]},
4: {color: silver, views: [{name: "front}, {name: "back}, {name: "top}, {name: "bottom}]},
}


How can I return an array of the following objects that have all front, back, top, and bottom using ES6 map/filter/some and etc?:



result =[
{colorId: "12", views: [{name: "front}, {name: "back}, {name: "top}, {name: "bottom}]}
{colorId: "73", views: [{name: "front}, {name: "back}, {name: "top}, {name: "bottom}]}
{colorId: "4", views: [{name: "front}, {name: "back}, {name: "top}, {name: "bottom}]}
]


I did it here but I feel like it is too messy and hard to read. Anybody could recommend on how to shorten it and make it easier to read using the ES6 functions (map, filter ...)?



 const result = idArray.map(id => {
const bluePrint = bluePrints[id];
const exists = blurPrint.views.some(view => view.name === 'top' || view.name === 'bottom');

if (exists) {
return {
colorId: id,
views: bluePrint.views
}
}
}).filter(bluePrint => !bluePrint);









share|improve this question


















  • 2




    Questions on how to optimize working code are better suited to be asked on codereview.stackexchange.com . You could use one reduce() instead of chaining map() and filter()
    – charlietfl
    Nov 15 at 18:05










  • You have lots of missing quotes in your original array and desired result.
    – Barmar
    Nov 15 at 18:14










  • Another typo: blurPrint should be bluePrint
    – Barmar
    Nov 15 at 18:19










  • bluePrint => !bluePrint should be bluePrint => bluePrint, otherwise you'll just get an array of undefined.
    – Barmar
    Nov 15 at 18:20















up vote
1
down vote

favorite









up vote
1
down vote

favorite











I have this array const idArray = ["12", "231", "73", "4"] and an object



const blueprints = {
12: {color: red, views: [{name: "front}, {name: "back}, {name: "top}, {name: "bottom}]},
231: {color: white, views: [{name: "front}, {name: "back}]},
73: {color: black, views: [{name: "front}, {name: "back}, {name: "top}, {name: "bottom}]},
4: {color: silver, views: [{name: "front}, {name: "back}, {name: "top}, {name: "bottom}]},
}


How can I return an array of the following objects that have all front, back, top, and bottom using ES6 map/filter/some and etc?:



result =[
{colorId: "12", views: [{name: "front}, {name: "back}, {name: "top}, {name: "bottom}]}
{colorId: "73", views: [{name: "front}, {name: "back}, {name: "top}, {name: "bottom}]}
{colorId: "4", views: [{name: "front}, {name: "back}, {name: "top}, {name: "bottom}]}
]


I did it here but I feel like it is too messy and hard to read. Anybody could recommend on how to shorten it and make it easier to read using the ES6 functions (map, filter ...)?



 const result = idArray.map(id => {
const bluePrint = bluePrints[id];
const exists = blurPrint.views.some(view => view.name === 'top' || view.name === 'bottom');

if (exists) {
return {
colorId: id,
views: bluePrint.views
}
}
}).filter(bluePrint => !bluePrint);









share|improve this question













I have this array const idArray = ["12", "231", "73", "4"] and an object



const blueprints = {
12: {color: red, views: [{name: "front}, {name: "back}, {name: "top}, {name: "bottom}]},
231: {color: white, views: [{name: "front}, {name: "back}]},
73: {color: black, views: [{name: "front}, {name: "back}, {name: "top}, {name: "bottom}]},
4: {color: silver, views: [{name: "front}, {name: "back}, {name: "top}, {name: "bottom}]},
}


How can I return an array of the following objects that have all front, back, top, and bottom using ES6 map/filter/some and etc?:



result =[
{colorId: "12", views: [{name: "front}, {name: "back}, {name: "top}, {name: "bottom}]}
{colorId: "73", views: [{name: "front}, {name: "back}, {name: "top}, {name: "bottom}]}
{colorId: "4", views: [{name: "front}, {name: "back}, {name: "top}, {name: "bottom}]}
]


I did it here but I feel like it is too messy and hard to read. Anybody could recommend on how to shorten it and make it easier to read using the ES6 functions (map, filter ...)?



 const result = idArray.map(id => {
const bluePrint = bluePrints[id];
const exists = blurPrint.views.some(view => view.name === 'top' || view.name === 'bottom');

if (exists) {
return {
colorId: id,
views: bluePrint.views
}
}
}).filter(bluePrint => !bluePrint);






javascript ecmascript-6






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 15 at 17:57









j doe

61




61








  • 2




    Questions on how to optimize working code are better suited to be asked on codereview.stackexchange.com . You could use one reduce() instead of chaining map() and filter()
    – charlietfl
    Nov 15 at 18:05










  • You have lots of missing quotes in your original array and desired result.
    – Barmar
    Nov 15 at 18:14










  • Another typo: blurPrint should be bluePrint
    – Barmar
    Nov 15 at 18:19










  • bluePrint => !bluePrint should be bluePrint => bluePrint, otherwise you'll just get an array of undefined.
    – Barmar
    Nov 15 at 18:20
















  • 2




    Questions on how to optimize working code are better suited to be asked on codereview.stackexchange.com . You could use one reduce() instead of chaining map() and filter()
    – charlietfl
    Nov 15 at 18:05










  • You have lots of missing quotes in your original array and desired result.
    – Barmar
    Nov 15 at 18:14










  • Another typo: blurPrint should be bluePrint
    – Barmar
    Nov 15 at 18:19










  • bluePrint => !bluePrint should be bluePrint => bluePrint, otherwise you'll just get an array of undefined.
    – Barmar
    Nov 15 at 18:20










2




2




Questions on how to optimize working code are better suited to be asked on codereview.stackexchange.com . You could use one reduce() instead of chaining map() and filter()
– charlietfl
Nov 15 at 18:05




Questions on how to optimize working code are better suited to be asked on codereview.stackexchange.com . You could use one reduce() instead of chaining map() and filter()
– charlietfl
Nov 15 at 18:05












You have lots of missing quotes in your original array and desired result.
– Barmar
Nov 15 at 18:14




You have lots of missing quotes in your original array and desired result.
– Barmar
Nov 15 at 18:14












Another typo: blurPrint should be bluePrint
– Barmar
Nov 15 at 18:19




Another typo: blurPrint should be bluePrint
– Barmar
Nov 15 at 18:19












bluePrint => !bluePrint should be bluePrint => bluePrint, otherwise you'll just get an array of undefined.
– Barmar
Nov 15 at 18:20






bluePrint => !bluePrint should be bluePrint => bluePrint, otherwise you'll just get an array of undefined.
– Barmar
Nov 15 at 18:20














3 Answers
3






active

oldest

votes

















up vote
0
down vote













You can filter ids so that every color in your target set of colors is in that id's blueprint.views and then map those ids to your desired result object:






const idArray = ["12", "231", "73", "4"];
const blueprints = {
12: {color: 'red', views: [{name: "front"}, {name: "back"}, {name: "top"}, {name: "bottom"}]},
231: {color: 'white', views: [{name: "front"}, {name: "back"}]},
73: {color: 'black', views: [{name: "front"}, {name: "back"}, {name: "top"}, {name: "bottom"}]},
4: {color: 'silver', views: [{name: "front"}, {name: "back"}, {name: "top"}, {name: "bottom"}]},
};

const result = idArray
.filter(id => {
const colors = blueprints[id].views.map(e => e.name);
return ['front', 'back', 'top', 'bottom'].every(s => colors.includes(s));
})
.map(id => ({colorId: id, views: blueprints[id].views}))

console.log(result);








share|improve this answer






























    up vote
    0
    down vote













    You can map() over your idArray to create the array in the desired format, then use filter() to test if every() required string is in the view array and filter out the incomplete items:






    const blueprints = {
    12: {color: "red", views: [{name: "front"}, {name: "back"}, {name: "top"}, {name: "bottom"}]},
    231: {color: "white", views: [{name: "front"}, {name: "back"}]},
    73: {color: "black", views: [{name: "front"}, {name: "back"}, {name: "top"}, {name: "bottom"}]},
    4: {color: "silver", views: [{name: "front"}, {name: "back"}, {name: "top"}, {name: "bottom"}]},
    }

    const idArray = ["12", "231", "73", "4"]
    const required = ['front', 'back', 'top', 'bottom']

    let newArry = idArray
    .map(colorID => ({colorID, views: blueprints[colorID].views }) )
    .filter(item => required.every(direction => item.views.some(v => v.name == direction) ))

    console.log(newArry)








    share|improve this answer






























      up vote
      0
      down vote













      Object.keys(blueprints)
      .map(k => ({colorId:k, views:blueprints[k].views}))
      .filter(el =>
      ['front', 'back', 'top', 'bottom'].every(it =>
      el.views.some(s => s.name === it)
      )
      )





      share|improve this answer























        Your Answer






        StackExchange.ifUsing("editor", function () {
        StackExchange.using("externalEditor", function () {
        StackExchange.using("snippets", function () {
        StackExchange.snippets.init();
        });
        });
        }, "code-snippets");

        StackExchange.ready(function() {
        var channelOptions = {
        tags: "".split(" "),
        id: "1"
        };
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function() {
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled) {
        StackExchange.using("snippets", function() {
        createEditor();
        });
        }
        else {
        createEditor();
        }
        });

        function createEditor() {
        StackExchange.prepareEditor({
        heartbeatType: 'answer',
        convertImagesToLinks: true,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: 10,
        bindNavPrevention: true,
        postfix: "",
        imageUploader: {
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        },
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        });


        }
        });














        draft saved

        draft discarded


















        StackExchange.ready(
        function () {
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53325368%2fextracting-data-in-es6%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes








        up vote
        0
        down vote













        You can filter ids so that every color in your target set of colors is in that id's blueprint.views and then map those ids to your desired result object:






        const idArray = ["12", "231", "73", "4"];
        const blueprints = {
        12: {color: 'red', views: [{name: "front"}, {name: "back"}, {name: "top"}, {name: "bottom"}]},
        231: {color: 'white', views: [{name: "front"}, {name: "back"}]},
        73: {color: 'black', views: [{name: "front"}, {name: "back"}, {name: "top"}, {name: "bottom"}]},
        4: {color: 'silver', views: [{name: "front"}, {name: "back"}, {name: "top"}, {name: "bottom"}]},
        };

        const result = idArray
        .filter(id => {
        const colors = blueprints[id].views.map(e => e.name);
        return ['front', 'back', 'top', 'bottom'].every(s => colors.includes(s));
        })
        .map(id => ({colorId: id, views: blueprints[id].views}))

        console.log(result);








        share|improve this answer



























          up vote
          0
          down vote













          You can filter ids so that every color in your target set of colors is in that id's blueprint.views and then map those ids to your desired result object:






          const idArray = ["12", "231", "73", "4"];
          const blueprints = {
          12: {color: 'red', views: [{name: "front"}, {name: "back"}, {name: "top"}, {name: "bottom"}]},
          231: {color: 'white', views: [{name: "front"}, {name: "back"}]},
          73: {color: 'black', views: [{name: "front"}, {name: "back"}, {name: "top"}, {name: "bottom"}]},
          4: {color: 'silver', views: [{name: "front"}, {name: "back"}, {name: "top"}, {name: "bottom"}]},
          };

          const result = idArray
          .filter(id => {
          const colors = blueprints[id].views.map(e => e.name);
          return ['front', 'back', 'top', 'bottom'].every(s => colors.includes(s));
          })
          .map(id => ({colorId: id, views: blueprints[id].views}))

          console.log(result);








          share|improve this answer

























            up vote
            0
            down vote










            up vote
            0
            down vote









            You can filter ids so that every color in your target set of colors is in that id's blueprint.views and then map those ids to your desired result object:






            const idArray = ["12", "231", "73", "4"];
            const blueprints = {
            12: {color: 'red', views: [{name: "front"}, {name: "back"}, {name: "top"}, {name: "bottom"}]},
            231: {color: 'white', views: [{name: "front"}, {name: "back"}]},
            73: {color: 'black', views: [{name: "front"}, {name: "back"}, {name: "top"}, {name: "bottom"}]},
            4: {color: 'silver', views: [{name: "front"}, {name: "back"}, {name: "top"}, {name: "bottom"}]},
            };

            const result = idArray
            .filter(id => {
            const colors = blueprints[id].views.map(e => e.name);
            return ['front', 'back', 'top', 'bottom'].every(s => colors.includes(s));
            })
            .map(id => ({colorId: id, views: blueprints[id].views}))

            console.log(result);








            share|improve this answer














            You can filter ids so that every color in your target set of colors is in that id's blueprint.views and then map those ids to your desired result object:






            const idArray = ["12", "231", "73", "4"];
            const blueprints = {
            12: {color: 'red', views: [{name: "front"}, {name: "back"}, {name: "top"}, {name: "bottom"}]},
            231: {color: 'white', views: [{name: "front"}, {name: "back"}]},
            73: {color: 'black', views: [{name: "front"}, {name: "back"}, {name: "top"}, {name: "bottom"}]},
            4: {color: 'silver', views: [{name: "front"}, {name: "back"}, {name: "top"}, {name: "bottom"}]},
            };

            const result = idArray
            .filter(id => {
            const colors = blueprints[id].views.map(e => e.name);
            return ['front', 'back', 'top', 'bottom'].every(s => colors.includes(s));
            })
            .map(id => ({colorId: id, views: blueprints[id].views}))

            console.log(result);








            const idArray = ["12", "231", "73", "4"];
            const blueprints = {
            12: {color: 'red', views: [{name: "front"}, {name: "back"}, {name: "top"}, {name: "bottom"}]},
            231: {color: 'white', views: [{name: "front"}, {name: "back"}]},
            73: {color: 'black', views: [{name: "front"}, {name: "back"}, {name: "top"}, {name: "bottom"}]},
            4: {color: 'silver', views: [{name: "front"}, {name: "back"}, {name: "top"}, {name: "bottom"}]},
            };

            const result = idArray
            .filter(id => {
            const colors = blueprints[id].views.map(e => e.name);
            return ['front', 'back', 'top', 'bottom'].every(s => colors.includes(s));
            })
            .map(id => ({colorId: id, views: blueprints[id].views}))

            console.log(result);





            const idArray = ["12", "231", "73", "4"];
            const blueprints = {
            12: {color: 'red', views: [{name: "front"}, {name: "back"}, {name: "top"}, {name: "bottom"}]},
            231: {color: 'white', views: [{name: "front"}, {name: "back"}]},
            73: {color: 'black', views: [{name: "front"}, {name: "back"}, {name: "top"}, {name: "bottom"}]},
            4: {color: 'silver', views: [{name: "front"}, {name: "back"}, {name: "top"}, {name: "bottom"}]},
            };

            const result = idArray
            .filter(id => {
            const colors = blueprints[id].views.map(e => e.name);
            return ['front', 'back', 'top', 'bottom'].every(s => colors.includes(s));
            })
            .map(id => ({colorId: id, views: blueprints[id].views}))

            console.log(result);






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 15 at 18:30

























            answered Nov 15 at 18:21









            slider

            7,8751129




            7,8751129
























                up vote
                0
                down vote













                You can map() over your idArray to create the array in the desired format, then use filter() to test if every() required string is in the view array and filter out the incomplete items:






                const blueprints = {
                12: {color: "red", views: [{name: "front"}, {name: "back"}, {name: "top"}, {name: "bottom"}]},
                231: {color: "white", views: [{name: "front"}, {name: "back"}]},
                73: {color: "black", views: [{name: "front"}, {name: "back"}, {name: "top"}, {name: "bottom"}]},
                4: {color: "silver", views: [{name: "front"}, {name: "back"}, {name: "top"}, {name: "bottom"}]},
                }

                const idArray = ["12", "231", "73", "4"]
                const required = ['front', 'back', 'top', 'bottom']

                let newArry = idArray
                .map(colorID => ({colorID, views: blueprints[colorID].views }) )
                .filter(item => required.every(direction => item.views.some(v => v.name == direction) ))

                console.log(newArry)








                share|improve this answer



























                  up vote
                  0
                  down vote













                  You can map() over your idArray to create the array in the desired format, then use filter() to test if every() required string is in the view array and filter out the incomplete items:






                  const blueprints = {
                  12: {color: "red", views: [{name: "front"}, {name: "back"}, {name: "top"}, {name: "bottom"}]},
                  231: {color: "white", views: [{name: "front"}, {name: "back"}]},
                  73: {color: "black", views: [{name: "front"}, {name: "back"}, {name: "top"}, {name: "bottom"}]},
                  4: {color: "silver", views: [{name: "front"}, {name: "back"}, {name: "top"}, {name: "bottom"}]},
                  }

                  const idArray = ["12", "231", "73", "4"]
                  const required = ['front', 'back', 'top', 'bottom']

                  let newArry = idArray
                  .map(colorID => ({colorID, views: blueprints[colorID].views }) )
                  .filter(item => required.every(direction => item.views.some(v => v.name == direction) ))

                  console.log(newArry)








                  share|improve this answer

























                    up vote
                    0
                    down vote










                    up vote
                    0
                    down vote









                    You can map() over your idArray to create the array in the desired format, then use filter() to test if every() required string is in the view array and filter out the incomplete items:






                    const blueprints = {
                    12: {color: "red", views: [{name: "front"}, {name: "back"}, {name: "top"}, {name: "bottom"}]},
                    231: {color: "white", views: [{name: "front"}, {name: "back"}]},
                    73: {color: "black", views: [{name: "front"}, {name: "back"}, {name: "top"}, {name: "bottom"}]},
                    4: {color: "silver", views: [{name: "front"}, {name: "back"}, {name: "top"}, {name: "bottom"}]},
                    }

                    const idArray = ["12", "231", "73", "4"]
                    const required = ['front', 'back', 'top', 'bottom']

                    let newArry = idArray
                    .map(colorID => ({colorID, views: blueprints[colorID].views }) )
                    .filter(item => required.every(direction => item.views.some(v => v.name == direction) ))

                    console.log(newArry)








                    share|improve this answer














                    You can map() over your idArray to create the array in the desired format, then use filter() to test if every() required string is in the view array and filter out the incomplete items:






                    const blueprints = {
                    12: {color: "red", views: [{name: "front"}, {name: "back"}, {name: "top"}, {name: "bottom"}]},
                    231: {color: "white", views: [{name: "front"}, {name: "back"}]},
                    73: {color: "black", views: [{name: "front"}, {name: "back"}, {name: "top"}, {name: "bottom"}]},
                    4: {color: "silver", views: [{name: "front"}, {name: "back"}, {name: "top"}, {name: "bottom"}]},
                    }

                    const idArray = ["12", "231", "73", "4"]
                    const required = ['front', 'back', 'top', 'bottom']

                    let newArry = idArray
                    .map(colorID => ({colorID, views: blueprints[colorID].views }) )
                    .filter(item => required.every(direction => item.views.some(v => v.name == direction) ))

                    console.log(newArry)








                    const blueprints = {
                    12: {color: "red", views: [{name: "front"}, {name: "back"}, {name: "top"}, {name: "bottom"}]},
                    231: {color: "white", views: [{name: "front"}, {name: "back"}]},
                    73: {color: "black", views: [{name: "front"}, {name: "back"}, {name: "top"}, {name: "bottom"}]},
                    4: {color: "silver", views: [{name: "front"}, {name: "back"}, {name: "top"}, {name: "bottom"}]},
                    }

                    const idArray = ["12", "231", "73", "4"]
                    const required = ['front', 'back', 'top', 'bottom']

                    let newArry = idArray
                    .map(colorID => ({colorID, views: blueprints[colorID].views }) )
                    .filter(item => required.every(direction => item.views.some(v => v.name == direction) ))

                    console.log(newArry)





                    const blueprints = {
                    12: {color: "red", views: [{name: "front"}, {name: "back"}, {name: "top"}, {name: "bottom"}]},
                    231: {color: "white", views: [{name: "front"}, {name: "back"}]},
                    73: {color: "black", views: [{name: "front"}, {name: "back"}, {name: "top"}, {name: "bottom"}]},
                    4: {color: "silver", views: [{name: "front"}, {name: "back"}, {name: "top"}, {name: "bottom"}]},
                    }

                    const idArray = ["12", "231", "73", "4"]
                    const required = ['front', 'back', 'top', 'bottom']

                    let newArry = idArray
                    .map(colorID => ({colorID, views: blueprints[colorID].views }) )
                    .filter(item => required.every(direction => item.views.some(v => v.name == direction) ))

                    console.log(newArry)






                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Nov 15 at 18:34

























                    answered Nov 15 at 18:24









                    Mark Meyer

                    33k32854




                    33k32854






















                        up vote
                        0
                        down vote













                        Object.keys(blueprints)
                        .map(k => ({colorId:k, views:blueprints[k].views}))
                        .filter(el =>
                        ['front', 'back', 'top', 'bottom'].every(it =>
                        el.views.some(s => s.name === it)
                        )
                        )





                        share|improve this answer



























                          up vote
                          0
                          down vote













                          Object.keys(blueprints)
                          .map(k => ({colorId:k, views:blueprints[k].views}))
                          .filter(el =>
                          ['front', 'back', 'top', 'bottom'].every(it =>
                          el.views.some(s => s.name === it)
                          )
                          )





                          share|improve this answer

























                            up vote
                            0
                            down vote










                            up vote
                            0
                            down vote









                            Object.keys(blueprints)
                            .map(k => ({colorId:k, views:blueprints[k].views}))
                            .filter(el =>
                            ['front', 'back', 'top', 'bottom'].every(it =>
                            el.views.some(s => s.name === it)
                            )
                            )





                            share|improve this answer














                            Object.keys(blueprints)
                            .map(k => ({colorId:k, views:blueprints[k].views}))
                            .filter(el =>
                            ['front', 'back', 'top', 'bottom'].every(it =>
                            el.views.some(s => s.name === it)
                            )
                            )






                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Nov 16 at 6:17

























                            answered Nov 15 at 18:39









                            dee zg

                            4,34531330




                            4,34531330






























                                draft saved

                                draft discarded




















































                                Thanks for contributing an answer to Stack Overflow!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid



                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.


                                To learn more, see our tips on writing great answers.





                                Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                Please pay close attention to the following guidance:


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid



                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.


                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function () {
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53325368%2fextracting-data-in-es6%23new-answer', 'question_page');
                                }
                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

                                ComboBox Display Member on multiple fields

                                Is it possible to collect Nectar points via Trainline?