Enfield-LiE
Reactiflux5y ago
6 replies
Enfield-Li

Enfield-li – 18-14 Feb 9

Guys, Please help me out, I am not able to get the return value of this code
Only got undefined from both values, but why..

let err = { someJunk: "asdfklasdf", detail: "email is bad" };
let fields = ["username", "email"];
const validation = (errDetail, fields) => {
fields.forEach((field) => {
if (errDetail.includes(field)) {
console.log("caught email");
return {
errors: {
field: field,
message: field + "already taken"
}
};
}
return;
});
};

const res = validation(err.detail, fields);
console.log(res);

https://codesandbox.io/s/crimson-framework-yn9i1?file=/src/index.js
CodeSandbox1076462153
crimson-framework-yn9i1 by 1076462153 using parcel-bundler
crimson-framework-yn9i1 - CodeSandbox
Was this page helpful?