Advertisement
teofarov13

Untitled

Mar 27th, 2021
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function balls(input) {
  2.     let index = 0
  3.     let ballsCount = input[index];
  4.     index++
  5.     let comand = input[index];
  6.     index++
  7.     let points = 0
  8.     let tottalPoints = 0
  9.  
  10.     let red = 0
  11.     let orange = 0
  12.     let yellow = 0
  13.     let white = 0
  14.     let black = 0
  15.     let otherColor = 0
  16.     while (comand != input.lengt) {
  17.         if (comand == input.length) {
  18.             break;
  19.         }
  20.         let color = input[index - 1];
  21.  
  22.  
  23.         if (color == "red") {
  24.             red++
  25.             points += 5;
  26.             tottalPoints = points
  27.         } else if (color == "orange") {
  28.             orange++
  29.             points += 10;
  30.             tottalPoints = points
  31.         } else if (color == "yellow") {
  32.             yellow++;
  33.             points += 15
  34.             tottalPoints = points
  35.         } else if (color == "white") {
  36.             white++
  37.             points += 20;
  38.             tottalPoints = points
  39.         } else if (color == "black") {
  40.             black++
  41.             tottalPoints = tottalPoints / 2
  42.         } else if (color !== "red" || color !== "orange" || color !== "yellow" || color !== "white" || color !== "black") {
  43.             otherColor++
  44.         }
  45.         // tottalPoints += points
  46.         tottalPoints = tottalPoints
  47.         comand = input[index]
  48.         index++
  49.     }
  50.     console.log(`Total points: ${tottalPoints}`);
  51.     console.log(`Points from red balls: ${red}`);
  52.     console.log(`Points from orange balls: ${orange}`);
  53.     console.log(`Points from yellow balls: ${yellow}`);
  54.     console.log(`Points from white balls: ${white}`);
  55.     console.log(`Other colors picked: ${otherColor}`)
  56.     console.log(`Divides from black balls: ${black}`);
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement