Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>HW1

<script src="main.js"></script>
</body>
</html>
56 changes: 56 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
(function () {
'use strict';
var cinemas, films, manager;
//functions
function createCinema(name, address, films, options) {
options = options || {};
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

зачем вы передаете опции, которые неиспользуете

return {
name: name,
address: address,
films: films
};
}

function createFilm(name, time, price, options) {
options = options || {};
return {
name: name,
time: time,
price: price
};
}

function createUser(coordinate, options) {
options = options || {};
return {
coordinate: coordinate
};
}

//base
films = [1, 2, 3, 4, 5, 6, 7].map(function (name, time) {
return createFilm(name, time, Math.random());
});

cinemas = ['Roliks', 'Salut', 'TitanicCinama'].map(function (name, address) {
var filmsList, i, film;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var filmsList = [], i, film;

filmsList = [];
for (i = 0; i < 3; i = i + 1) {
film = films[Math.floor(Math.random() * (films.lenght + 1))];
filmsList.push(film);
}
return createCinema(name, address, films);
});

//Manager
manager = {};
manager.findByFilmName = function (film) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

у вас менеджер какой-то грустный научите его еще чему нибудь

var i, j;
for (i = 0; i < cinemas.lenght; i = i + 1) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Часто код с форами можно переписать на код без них

return Array.prototype.concat.apply([], cinamas.map(function (cinema) {
  return cinema.films.filter(function (film) {
    return film.name === filmName;
  }
});

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

такой код можно читать как английские предложения

for (j = 0; j < cinemas[i].films.lenght; j = j + 1) {
if (cinemas[i].films[j].name === film) {
return cinemas[i];
}
}
}
}());