Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
$(".score").each(function(){
var commentRating = $(this).text();
if(commentRating > 7)
console.log(commentRating);
else if(commentRating < -7)
console.log(commentRating);
else $(this).text("");
});
javascript:$(".score").each(function(){var commentRating = $(this).text();if(commentRating<7&&commentRating>-7)$(this).text("");})commentRating.replace("–","-");javascript:$(".score").each(function(){var commentRating = $(this).text().replace('–','-');if(commentRating<7&&commentRating>-7)$(this).text("");})var bestComments = [];
var badComments = [];
var commentsList = $(".comments_list");
$(".score").each(function(){
var commentRating = $(this).text().replace("–","-");
var comment = $(this).parent().parent().parent().parent().parent();
if(commentRating > 7)
{
bestComments.push(comment.clone());
}
else if(commentRating < -7)
{
badComments.push(comment.clone());
}
else $(this).text("");
});
var sortFunction = function(a, b){
if( $(".score",a).text().replace("–","-") < $(".score",b).text().replace("–","-") )
return -1;
if( $(".score",a).text().replace("–","-") > $(".score",b).text().replace("–","-") )
return 1;
return 0;
};
bestComments.sort(sortFunction);
badComments.sort(sortFunction);
bestComments.forEach(function(element){
commentsList.prepend(element);
});
commentsList.prepend("<div><h1>Лучшие комментарии:</h1></div><br>");
commentsList.append("<div><h1>Худшие комментарии:</h1></div><br>");
badComments.forEach(function(element){
commentsList.append(element);
});

интернет-пользователи имеют тенденцию следовать за стадом
Стадный эффект голосующих. Мууу… Исследование MIT'а