function generateLastVisit() {
const randomNumber = Math.floor(Math.random() * 10) +1;
const date = new Date()
date.setDate(date.getDate() - randomNumber)
return date;
}
function initializeClassRoomData(currentClassRoom){
let isFull = false;
let countOfComputers = currentClassRoom.countOfSeates;
while(!isFull) {
const student = new Object();
student.name = "Student - " + countOfComputers;
student.age = countOfComputers % 2 == 0 ? countOfComputers * 2 : Math.floor(countOfComputers * 1.8) ;
student.student_number = countOfComputers;
student.lastVisit = generateLastVisit();
const computer = new Object();
computer.computer_number = student.student_number;
computer.isWorking = countOfComputers % 2 == 0 ? true : false;
computer.student_name = student.name;
if(countOfComputers < 1) {
isFull = true
}else{
currentClassRoom.students.push(student)
currentClassRoom.computers.push(computer)
countOfComputers--
}
}
}
initializeClassRoomData(classRoom)
const info = {
name: "Имя",
age: 25,
lastVisit: new Date(),
computer_number: 5
}