-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rock off!.js
37 lines (26 loc) · 1.73 KB
/
Rock off!.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
https://www.codewars.com/kata/5b097da6c3323ac067000036
Alice and Bob have participated to a Rock Off with their bands. A jury of true metalheads rates the two challenges, awarding points to the bands on a scale from 1 to 50 for three categories: Song Heaviness, Originality, and Members' outfits.
For each one of these 3 categories they are going to be awarded one point, should they get a better judgement from the jury. No point is awarded in case of an equal vote.
You are going to receive two arrays, containing first the score of Alice's band and then those of Bob's. Your task is to find their total score by comparing them in a single line.
Example:
Alice's band plays a Nirvana inspired grunge and has been rated 20 for Heaviness, 32 for Originality and only 18 for Outfits. Bob listens to Slayer and has gotten a good 48 for Heaviness, 25 for Originality and a rather honest 40 for Outfits.
The total score should be followed by a colon : and by one of the following quotes: if Alice's band wins: Alice made "Kurt" proud! if Bob's band wins: Bob made "Jeff" proud! if they end up with a draw: that looks like a "draw"! Rock on!
The solution to the example above should therefore appear like '1, 2: Bob made "Jeff" proud!'.
function solve(a, b) {
let alice = 0;
let bob = 0;
if (a[0] > b[0]) alice++;
else if (a[0] < b[0]) bob++;
else alice = alice; bob = bob;
if (a[1] > b[1]) alice++;
else if (a[1] < b[1]) bob++;
else alice = alice; bob = bob;
if (a[2] > b[2]) alice++;
else if (a[2] < b[2]) bob++;
else alice = alice; bob = bob;
return alice > bob ?
`${alice}, ${bob}: Alice made "Kurt" proud!`:
alice === bob ?
`${alice}, ${bob}: that looks like a "draw"! Rock on!`:
`${alice}, ${bob}: Bob made "Jeff" proud!`;
}