Skip to content

Commit 599202d

Browse files
authored
refactor: Use substring instead of substr (#2021)
1 parent e90d618 commit 599202d

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

exercises/practice/ocr-numbers/.meta/proof.ci.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const splitIntoDigits = (row) => {
3030
for (let digitNumber = 0; digitNumber < rows[0].length; digitNumber += 3) {
3131
let digit = '';
3232
for (let rowNumber = 0; rowNumber < rows.length; rowNumber += 1) {
33-
digit += rows[rowNumber].substr(digitNumber, 3);
33+
digit += rows[rowNumber].substring(digitNumber, digitNumber + 3);
3434
}
3535
digits.push(digit);
3636
}

exercises/practice/robot-name/robot-name.spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { Robot } from './robot-name';
22

33
const areSequential = (name1, name2) => {
4-
const alpha1 = name1.substr(0, 2);
5-
const alpha2 = name2.substr(0, 2);
6-
const num1 = Number(name1.substr(2, 3));
7-
const num2 = Number(name2.substr(2, 3));
4+
const alpha1 = name1.substring(0, 2);
5+
const alpha2 = name2.substring(0, 2);
6+
const num1 = Number(name1.substring(2, 5));
7+
const num2 = Number(name2.substring(2, 5));
88

99
const numDiff = num2 - num1;
1010
const alphaDiff =

exercises/practice/simple-cipher/simple-cipher.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ describe('Random key cipher', () => {
88
// Here we take advantage of the fact that plaintext of "aaa..."
99
// outputs the key. This is a critical problem with shift ciphers, some
1010
// characters will always output the key verbatim.
11-
expect(cipher.encode('aaaaaaaaaa')).toEqual(cipher.key.substr(0, 10));
11+
expect(cipher.encode('aaaaaaaaaa')).toEqual(cipher.key.substring(0, 10));
1212
});
1313

1414
xtest('can decode', () => {
15-
expect(cipher.decode(cipher.key.substr(0, 10))).toEqual('aaaaaaaaaa');
15+
expect(cipher.decode(cipher.key.substring(0, 10))).toEqual('aaaaaaaaaa');
1616
});
1717

1818
xtest('is reversible', () => {

0 commit comments

Comments
 (0)