Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function computerFirm(input) {
- let models = Number(input[0]);
- let sales = 0;
- let rating = 0;
- for (let i = 1; i <= models; i++) {
- let modelRating = Number(input[i]) % 10;
- let modelSales = Math.floor(Number(input[i]) / 10);
- if (modelRating === 2){
- sales += 0;
- } else if (modelRating === 3) {
- sales += modelSales / 100 * 50;
- } else if (modelRating === 4) {
- sales += modelSales / 100 * 70;
- } else if (modelRating === 5) {
- sales += modelSales / 100 * 85;
- } else if (modelRating === 6) {
- sales += modelSales;
- }
- rating += modelRating;
- }
- console.log(`${sales.toFixed(2)}`);
- console.log(`${(rating / models).toFixed(2)}`);
- }
Add Comment
Please, Sign In to add comment