Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Search - "payed per line"
-
It's truly incredible, what people can create:
let categoriesText = '';
categories.forEach((item, i) => {
if (i !== 0) {
categoriesText =
categoriesText + `, ${item.categoryName}`;
} else {
categoriesText =
categoriesText + `${item.categoryName}`;
}
});
return categoriesText
How about you STFU!!!
return categories.map((category) => category.categoryName).join(', ');12 -
You could do:
let categorysString = '';
categories.map((item, index) => {
if ( index === 0 ) {
categorysString = categorysString + `${item.categoryName}`;
} else {
categorysString = categorysString + `, ${item.categoryName}`;
}
});
Or you could just do:
return categories.map(category => category.categoryName).join(", ")
🙄
Previous company must have been payed per line...3