Using JavaScript and HTML, I created a page with links that take you to another page that are populated by object properties when the URL parameter matches a specified property.
This is the JS to get the parameter:
var urlParams = new URLSearchParams(window.location.search);
console.log(urlParams.get('title')); // Logs movie title like Black Panther
And the object array:
var movies = [{
"title" : "Black Panther",
"theatricalrelease" : "2/16/2018",
"description" : "Marvel Studios’ “Black Panther” follows T’Challa who, after the death of his father, the King of Wakanda, returns home to the isolated, technologically advanced African nation to succeed to the throne and take his rightful place as king.",
"image" : "https://i.ytimg.com/vi/2e52vw7RR-A/maxresdefault.jpg"
},
{
"title" : "Avengers: Infinity War",
"theatricalrelease" : "4/27/2018",
"description" : "As the Avengers and their allies have continued to protect the world from threats too large for any one hero to handle, a new danger has emerged from the cosmic shadows: Thanos.",
"image" : "http://sm.ign.com/ign_latam/screenshot/default/avengers-infinitywar-art-860x450-860x450-c_efps.png"
},
{
"title" : "Ant-Man and The Wasp",
"theatricalrelease" : "7/6/2018",
"description" : "From the Marvel Cinematic Universe comes a new chapter featuring heroes with the astonishing ability to shrink: “Ant-Man and The Wasp.”",
"image" : ""
}];
How can I find the correct object to populate the page using the URL parameter?