Answer the question
In order to leave comments, you need to log in
How to use the thisArg argument in the ForEach method?
Here is a piece of code that works as expected (fills selected table cells with color):
function renderTour(league, $table, round) {
var schedule = /*массив*/,
home,
away,
$currentCell;
schedule.forEach(function (match) {
home = match[0] + 1;
away = match[1] + 1;
$currentCell = $table.find('tr:eq(' + home + ')>td:eq(' + away + ')');
$currentCell.css('background-color', 'rgba(200, 100, 0, 0.2)');
});
}
function renderTour(league, $table, round) {
var schedule = /*массив*/,
home,
away,
$currentCell;
schedule.forEach(highlight);
}
function highlight(match) {
home = match[0] + 1;
away = match[1] + 1;
$currentCell = $table.find('tr:eq(' + home + ')>td:eq(' + away + ')');
$currentCell.css('background-color', 'rgba(200, 100, 0, 0.2)');
}
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