Files
5chan/src/utils/countLinks.js
T

20 lines
351 B
JavaScript

function countLinks(comment) {
let linkCount = 0;
if (comment.replyCount > 0) {
for (let reply of comment.replies.pages.topAll.comments) {
if (reply.link) {
linkCount++;
}
if (reply.replyCount > 0) {
linkCount += countLinks(reply);
}
}
}
return linkCount;
}
export default countLinks;