Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function division(input) {
- let total = Number(input[0]);
- let divByTwoCount = 0;
- let divByThreeCount = 0;
- let divByFourCount = 0;
- for (let i = 1; i < input.length; i++) {
- if (input[i] % 2 === 0) {
- divByTwoCount++;
- }
- if (input[i] % 3 === 0) {
- divByThreeCount++;
- }
- if (input[i] % 4 === 0) {
- divByFourCount++
- }
- }
- console.log(`${(divByTwoCount / total * 100).toFixed(2)}%\n${(divByThreeCount / total * 100).toFixed(2)}%\n${(divByFourCount / total * 100).toFixed(2)}%`);
- } division(["10", "680", "2", "600", "200", "800", "799", "199", "46", "128", "65"])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement