I'm attempting to create a variable that contains the value of an object.
the variable eventDateValue
below is what i'm struggling with. I'm trying to match the value of EventName
to the object events2020
and if there's a match (must match the object name) pass the value of that match to the variable eventDateValue
.
below is my code
function getPage(){
let pageActual = window.location.href;
console.log(pageActual);
let pageName = /127(.*)/;
let EventName = pageName.exec(pageActual);
console.log(EventName[1]);
const events2020 = {
Event1 :'February 19, 2020',
Event2 :'February 18, 2020',
Event3 :'February 17, 2020',
Event4 :'February 16, 2020',
Event5 :'February 15, 2020',
Event6 :'February 14, 2020'
};
let eventDateValue = Object.keys(events2020)
[Object.values(events2020).indexOf(EventName)]
console.log(eventDateValue);
}