Answer the question
In order to leave comments, you need to log in
What is the correct way to use a for loop?
Tell me about the for loop.
There are variables that store data from the form.
const name = req.body.name;
const email = req.body.email;
const arr = errors.array();
[ { location: 'body',
param: 'name',
value: '',
msg: 'Введите свое имя!' },
{ location: 'body',
param: 'email',
value: '',
msg: 'Проверьте правильность E-mail!' }
]
function nameField() {
for (const namearr of arr.values()) {
if (namearr.param !== "name") {
return name;
} else {
console.log("Такое имя существует!");
}
}
}
function emailField() {
for (const emailarr of arr.values()) {
if (emailarr.param !== "email") {
return email;
} else {
return console.log("Такой email существует!");
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question