-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathday06.js
52 lines (44 loc) · 1.65 KB
/
day06.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// ./day06.js
/*
Challenge #6 - Turn Out For What
Phew, with our help the city staff were able to select the voting stations on
time and the election went off without a hitch! Now that the votes have been
cast, the Election staff needs to verify the votes by matching each voter's
signature to their voter ID.
Instructions
Complete the function voterTurnout(), that will take in two arrays. The first
array is a list of voter ids, and the second array is a list of voter signatures,
which correspond to the voter ids. Our task here is to first check that each
array have the same number of items and then confirm that each of the voter ids
matches the corresponding voter signature.
If the arrays do not contain the same number of items, then we know something is
amiss and our function should return false. If they contain the same number of
elements, then we should proceed to check if the two arrays are identical,
meaning they contain the same names in the same order. If they are, our function
should return "All clear, we can count the votes!", if they are not it should
return "FRAUD!".
*/
const voterTurnout = (voter_signatures, voter_ids) => {
if (voter_signatures.length === voter_ids.length) {
return JSON.stringify(voter_signatures) === JSON.stringify(voter_ids)
? "All clear, we can count the votes!"
: "FRAUD!";
} else {
return false;
}
};
const voter_signatures = [
'Bill Billiamson',
'Kate Etak',
'Brandon Brandonus',
'Fake McFakerson',
'Jane Janesford'
];
const voter_ids = [
'Bill Billiamson',
'Kate Etak',
'Brandon Brandonus',
'Simon Simonson',
'Jane Janesford'
];
console.log(voterTurnout(voter_signatures, voter_ids));