Estoy buscando una manera de obtener todas las propiedades de correo electrónico de mi lista de postList para filtrar los caracteres máximos autorizados, el problema es que realmente no sé cómo mapear la propiedad de correo electrónico de postList ...
const postList = [ {"postId": 1, "id": 1, "email": "Eliseo@gardner.biz"}, {"postId": 1, "id": 2, "email": "Jayne_Kuhic@sydney.com"}, {"postId": 1, "id": 3, "email": "Nikita@garfield.biz"}, {"postId": 1, "id": 4, "email": "Lew@alysha.tv"}, ] const onlyEmailValid = [] for (let i = 0; i < postList.length; i++) { if(postList.email.value.length > max_chars) { console.log("email : " + postList.email + " has too long"); continue } onlyEmailValid.push(postList[i]); } console.log(clearJobList);Hola intenta usar el método de filter
const postList = [ {"postId": 1, "id": 1, "email": "Eliseo@gardner.biz"}, {"postId": 1, "id": 2, "email": "Jayne_Kuhic@sydney.com"}, {"postId": 1, "id": 3, "email": "Nikita@garfield.biz"}, {"postId": 1, "id": 4, "email": "Lew@alysha.tv"}, ] const onlyEmailValid = [] const max_chars = 13 postList.filter(item=>{ (item.email.length > max_chars) ? console.log("email : " + item.email + " has too long") : onlyEmailValid.push(item); }) console.log(onlyEmailValid); const postList = [ {"postId": 1, "id": 1, "email": "Eliseo@gardner.biz"}, {"postId": 1, "id": 2, "email": "Jayne_Kuhic@sydney.com"}, {"postId": 1, "id": 3, "email": "Nikita@garfield.biz"}, {"postId": 1, "id": 4, "email": "Lew@alysha.tv"}, ] const onlyEmailValid = [] const max_chars = 15 //example for (let i = 0; i < postList.length; i++) { if(postList[i].email.length > max_chars) { console.log("email : " + postList[i].email + " has too long"); continue } onlyEmailValid.push(postList[i]); } console.log(onlyEmailValid);