Closed tshemsedinov closed 2 years ago
'use strict';
function (message) {
const config = require('./config.js');
module.exports = { port: process.env.PORT || 80, api: { key: 'c33616c4ada296c918a35b2d9dbc7fb3', url: 'https://api.themoviedb.org/3/discover/movie', } // other paramaters... };
const commands = { CLIENTDATA: (ws, msg) => {}, NEWRATING: (ws, msg) => {}, };
let films = {};
==
===
const COMEDY = 35; { // or even implement function getGenreEndpoint(number): string const { url, key } = config.api; const endpoint = `${url}?api_key=${key}&with_genres=${COMEDY}`; }
const add = (a, b) => a + b; const avg = (arr) => arr.reduce(add, 0) / arr.length;
const record = ratings[film.id]; const result = record ? avg(record) : "No rating";
- Remove code duplicate code
Done!
'use strict';
function (message) {
const config = require('./config.js');
let films = {};
==
(use===
) because it can lead to type casting and we have common code-style to avoid==
at allconst record = ratings[film.id]; const result = record ? avg(record) : "No rating";