I am currently working with a variable containing JSON data.
var blogData = [
{
"blogTitle":"Bangladesh",
"imagePath":"/img/blog/bangladesh.jpg"
},{
"blogTitle":"India",
"imagePath":"/img/blog/india.jpg"
}
]
My goal is to create a new array called titleFilter as follows:
var titleFilter = [
Bangladesh : "/img/blog/bangladesh.jpg",
India : "/img/blog/india.jpg"
]
To achieve this, I have attempted the following code:
var titleFilter = [];
for (var i = 0; i < blogData.length; i++) {
titleFilter[blogData[i].blogTitle] = blogData[i].imagePath;
}
However, I am encountering an issue where the titleFilter array appears as:
var titleFilter = [
Bangladesh : "",
India : ""
]
If anyone could provide assistance with this problem, it would be greatly appreciated.