Skip to content

Commit

Permalink
Fix Linting in Index of Coincidence Operation
Browse files Browse the repository at this point in the history
  • Loading branch information
Ge0rg3 committed Jun 8, 2019
1 parent 36c8c03 commit 2db9409
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/core/operations/IndexOfCoincidence.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,20 @@ class IndexOfCoincidence extends Operation {
* @returns {number}
*/
run(input, args) {
const text = input.toLowerCase().replace(/[^a-z]/g, ''),
frequencies = new Array(26).fill(0),
alphabet = Utils.expandAlphRange("a-z")
const text = input.toLowerCase().replace(/[^a-z]/g, ""),
frequencies = new Array(26).fill(0),
alphabet = Utils.expandAlphRange("a-z");
let coincidence = 0.00,
density = 0.00,
result = 0.00,
i;

for (i=0; i < alphabet.length; i++) {
frequencies[i] = text.count(alphabet[i]);
frequencies[i] = text.count(alphabet[i]);
}

for (i=0; i < frequencies.length; i++) {
coincidence += frequencies[i] * (frequencies[i] - 1);
coincidence += frequencies[i] * (frequencies[i] - 1);
}

density = frequencies.sum();
Expand All @@ -67,7 +67,7 @@ class IndexOfCoincidence extends Operation {
* @returns {html}
*/
present(ic) {
return `Index of Coincidence: ${ic}
return `Index of Coincidence: ${ic}
Normalized: ${ic * 26}
<br><canvas id='chart-area'></canvas><br>
- 0 represents complete randomness (all characters are unique), whereas 1 represents no randomness (all characters are identical).
Expand Down Expand Up @@ -99,8 +99,8 @@ The graph shows the IC of the input data. A low IC generally means that the text
}
]);
</script>
`
}
`;
}

}

Expand Down

0 comments on commit 2db9409

Please sign in to comment.