Skip to content

Instantly share code, notes, and snippets.

@josephgoksu
Created August 16, 2020 20:20
Show Gist options
  • Save josephgoksu/52f25301e80c9d4f05d7f69f169201e3 to your computer and use it in GitHub Desktop.
Save josephgoksu/52f25301e80c9d4f05d7f69f169201e3 to your computer and use it in GitHub Desktop.
Billion Dollar Company First Code
const input = {
id: "286ba27a-dffb-11ea-87d0-0242ac130003",
rank: 4.75,
date: 120,
};
const input2 = {
id: "286ba27a-dffb-11ea-87d0-0242ac130003",
rank: 2.5,
date: 121,
};
const input3 = {
id: "286ba27a-dffb-11ea-87d0-0242ac130003",
rank: 3.75,
date: 1,
};
const input4 = {
id: "286ba27a-dffb-11ea-87d0-0242ac130003",
rank: 3.75,
date: 12,
};
const allInputs = [input, input2, input3];
// TELEVISION
const projectBusinessCase = {
lastHowManyDays: 120,
returnFirstProduct: {
value: 10,
},
returnLastProduct: {
value: 10,
shouldNotify: {
value: true,
notifyType: "email",
toWho: ["ademJoe@gmail.com", "adamJoe2@gmail.com"],
},
},
};
// LG 32MN19HM Televizyon
const productBusinessCase = {
shouldDeletedAtEvery: 60,
};
const calculateRank = (input, businessCase) => {
let rank = 0;
const howMany = input.length;
// BusinessCase
input.map((value, index) => {
if (value.date <= businessCase.lastHowManyDays) rank = rank + value.rank;
});
rank = rank / howMany;
return rank;
};
console.log(calculateRank(allInputs, projectBusinessCase).toFixed(2));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment