Query category via JSON with Javascript

I have this JSON file. I would like to query only the Post-Game categories, however, I need the last two of them.

    {
    "videos" : [
        {
            "url" : "https://www.youtube.com/watch?v=DSorwgunfqo",
            "category" : "Pre-Game",
            "team" : ["Rodholfo Silva"],
            "date" : "January 20th 2021"
        },
        {
            "url" : "https://www.youtube.com/watch?v=qFzxV0Dc2rw",
            "category" : "Post-Game",
            "team" : ["Rod Patrón"],
            "date" : "January 21st 2021"
        },
        {
            "url" : "https://www.youtube.com/watch?v=nq0358cJb-M",
            "category" : "Post-Game",
            "team" : ["Rod Patrón"],
            "date" : "January 17th 2021"
        },
        {
            "url" : "https://www.youtube.com/watch?v=iALl-ce5dzY",
            "category" : "Pre-Game",
            "team" : ["Rodholfo Silva"],
            "date" : "January 16th 2021"
        },
        {
            "url" : "https://www.youtube.com/watch?v=UY4WvV3dHNY",
            "category" : "Enterviews",
            "team" : ["Mathew Francis, Rodholfo Silva, Rod Patrón"],
            "date" : "July 16th 2020"
        },
        {
            "url" : "https://www.youtube.com/watch?v=7E2hMsmdbd4",
            "category" : "Post-Game",
            "team" : ["Rod Patrón"],
            "date" : "January 24th 2021"
        }
    ]
}

I am using Javascript, via for loops and slice(1).slice(-2), but not success.

99 thoughts on “Query category via JSON with Javascript”

Leave a Comment