Перекладывание бумажек без indexOf().

Мой вариант без применения методов массива (только разрешенный push) :grinning:

  var getDocumentsNumbers = function (documentsName, year) {
      var counter = 0;
      var yearToString = String(year);
      for (let i = 0; i < documentsName.length; i += 1) {
          var documentName = documentsName[i];
          var documentYear = [];
          for (let j = documentName.length - 2; j < documentName.length; j += 1) {
          documentYear.push(documentName[j]);
          }
          if (documentYear[0] === yearToString[2] && documentYear[1] === yearToString[3]) {
          counter++;
          }
      }
      return counter;
  }
1 Симпатия

var documentsName =[“20122011”,“03032012”,“20122012”,“09072011”];
var year = 2012;
var numbers = 0;

function getDocumentsNumbers (documentsName, year) {
for (var i = 0; i < documentsName.length; i++) {
var remains = Number(documentsName[i]) % 10000;
if (remains == year) {
numbers++
}
}
return numbers;
}

2 Симпатий
const getDocumentsNumbers = (documents,years) => {
  let count = 0;
  for (let document of documents) {
    if (document.endsWith(years) === true) {
      count++;
    }
  }

  return count;
}