var comment,
commentsList = [];
var getCommentsList = function() {
for (let i = 0; i < 3; i++) {
comment = "Привет, мир!";
commentsList.push(comment);
}
return commentsList;
};
var testArr = [];
for (let i = 0; i < 5; i++) {
testArr.push({
name: "Название объекта",
sometext: commentsList
});
}
getCommentsList()
console.log(testArr);
let object = {
param1: true,
param2: false,
param3: true
}
const getFormData = object => {
const formData = new FormData();
Object.keys(object).forEach(key => formData.append(key, object[key]));
return formData;
}
for (let value of getFormData(object).entries()) {
console.log(value);
}
function getDaysArray(year, month) {
var numDaysInMonth, daysInWeek, daysIndex, index, i, l, daysArray;
numDaysInMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
daysInWeek = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
daysIndex = { 'Sun': 0, 'Mon': 1, 'Tue': 2, 'Wed': 3, 'Thu': 4, 'Fri': 5, 'Sat': 6 };
index = daysIndex[(new Date(year, month - 1, 1)).toString().split(' ')[0]];
daysArray = [];
for (i = 0, l = numDaysInMonth[month - 1]; i < l; i++) {
daysArray.push({
year: year,
month: month,
number: (i + 1),
day: daysInWeek[index++]
})
if (index == 7) index = 0;
}
return daysArray;
}
console.log(getDaysArray(2019, 7))