Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input) {
- let totalPoints = 0;
- let pointRed = 0;
- let pointOrange = 0;
- let pointYellow = 0;
- let pointWhite = 0;
- let otherColor = 0;
- let countBlack = 0;
- for (let i = 1; i < input.length; i++) {
- if (input[i] === 'red') {
- totalPoints = totalPoints + 5;
- pointRed = pointRed + 1;
- } else if (input[i] === 'orange') {
- totalPoints = totalPoints + 10;
- pointOrange = pointOrange + 1;
- } else if (input[i] === 'yellow') {
- totalPoints = totalPoints + 15;
- pointYellow = pointYellow + 1;
- } else if (input[i] === 'white') {
- totalPoints = totalPoints + 20;
- pointWhite = pointWhite + 1;
- } else if (input[i] === 'black') {
- totalPoints = Math.floor(totalPoints / 2);
- countBlack = countBlack + 1;
- } else {
- otherColor = otherColor + 1;
- }
- }
- console.log(`Total points: ${totalPoints}`);
- console.log(`Points from red balls: ${pointRed}`);
- console.log(`Points from orange balls: ${pointOrange}`);
- console.log(`Points from yellow balls: ${pointYellow}`);
- console.log(`Points from white balls: ${pointWhite}`);
- console.log(`Other colors picked: ${otherColor}`);
- console.log(`Divides from black balls: ${countBlack}`);
- }
- solve(['3', 'white', 'black', 'pink']);
Advertisement
Add Comment
Please, Sign In to add comment