Advertisement
Liliana797979

division

Jan 31st, 2021
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function division(input) {
  2.     let total = Number(input[0]);
  3.     let divByTwoCount = 0;
  4.     let divByThreeCount = 0;
  5.     let divByFourCount = 0;
  6.     for (let i = 1; i < input.length; i++) {
  7.         if (input[i] % 2 === 0) {
  8.             divByTwoCount++;
  9.         }
  10.         if (input[i] % 3 === 0) {
  11.             divByThreeCount++;
  12.         }
  13.         if (input[i] % 4 === 0) {
  14.             divByFourCount++
  15.         }
  16.     }
  17.     console.log(`${(divByTwoCount / total * 100).toFixed(2)}%\n${(divByThreeCount / total * 100).toFixed(2)}%\n${(divByFourCount / total * 100).toFixed(2)}%`);
  18. } division(["10", "680", "2", "600", "200", "800", "799", "199", "46", "128", "65"])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement