You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
for (const field in issueFieldType) {
const type = issueFieldType[field];
if (!type) {
delete issue[field];
} else if (type === 'required' && !issue[field]) {
return `${field} is required.`;
}
}
we see that the if (!type) is redundant. because every type in issueFieldType is not undefind .
I think we should write issue instead of issueFieldType in the for statement:
for (const field in issue) {
const type = issueFieldType[field];
if (!type) {
delete issue[field];
} else if (type === 'required' && !issue[field]) {
return `${field} is required.`;
}
}
The resulted function is:
function validateIssue(issue) {
for (const field in issue) {
const type = issueFieldType[field];
if (!type) {
delete issue[field];
} else if (type === 'required' && !issue[field]) {
return `${field} is required.`;
}
}
if (!validIssueStatus[issue.status])
return `${issue.status} is not a valid status.`;
return null;
}
The text was updated successfully, but these errors were encountered:
If we see this part of
validateIssue
function:we see that the
if (!type)
is redundant. because everytype
inissueFieldType
is notundefind
.I think we should write
issue
instead ofissueFieldType
in thefor
statement:The resulted function is:
The text was updated successfully, but these errors were encountered: