I'm working on vanilla js since I'm not allowed to use jQuery at all, so I'm pretty much a beginner so I wanted a guide, I'm trying to get the email address from a JSON file I've tried doing a loop but it never gets to the attribute email and displays it.
I have tried this :
I search through an input text and get the value and store it in textValue then I try looking for that value with a for-loop
.
var textValue = document.getElementById("email").value;
for(var i = 0; i < localStorage.getItem(jsondata.data.length); i++)
{
if(jsondata[i].email == textValue)
{
console.log(jsondata[i].email)
}
}
};
This is how the JSON looks:
{
"data": [
{
"email": "nicobes@gmail.com",
"name": "Nickole Beatrice Smith",
"address": "398 Pleasant Pine Cir. Harrington, DE 19123",
"age": 45,
"notes": "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, ",
"phoneNumbers": [
{
"phone": "(302) 792-8434"
},
{
"phone": "(302) 792-1134"
},
{
"phone": "(302) 792-2234"
},
{
"phone": "(302) 792-3334"
}
],
"relatives": [
{
"name": "Susan M Smith"
},
{
"name": "Malcolm W Smith"
},
{}
]
}