Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function balls(input) {
- let index = 0
- let ballsCount = input[index];
- index++
- let comand = input[index];
- index++
- let points = 0
- let tottalPoints = 0
- let red = 0
- let orange = 0
- let yellow = 0
- let white = 0
- let black = 0
- let otherColor = 0
- while (comand != input.lengt) {
- if (comand == input.length) {
- break;
- }
- let color = input[index - 1];
- if (color == "red") {
- red++
- points += 5;
- tottalPoints = points
- } else if (color == "orange") {
- orange++
- points += 10;
- tottalPoints = points
- } else if (color == "yellow") {
- yellow++;
- points += 15
- tottalPoints = points
- } else if (color == "white") {
- white++
- points += 20;
- tottalPoints = points
- } else if (color == "black") {
- black++
- tottalPoints = tottalPoints / 2
- } else if (color !== "red" || color !== "orange" || color !== "yellow" || color !== "white" || color !== "black") {
- otherColor++
- }
- // tottalPoints += points
- tottalPoints = tottalPoints
- comand = input[index]
- index++
- }
- console.log(`Total points: ${tottalPoints}`);
- console.log(`Points from red balls: ${red}`);
- console.log(`Points from orange balls: ${orange}`);
- console.log(`Points from yellow balls: ${yellow}`);
- console.log(`Points from white balls: ${white}`);
- console.log(`Other colors picked: ${otherColor}`)
- console.log(`Divides from black balls: ${black}`);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement