Remove useless bounds check

This commit is contained in:
Johan Milanov 2024-02-24 18:10:52 +01:00 committed by GitHub
parent 1201a2f1bc
commit a3f1fb7956
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -97,10 +97,7 @@ class Scratch3OperatorsBlocks {
letterOf (args) {
const index = Cast.toNumber(args.LETTER) - 1;
const str = Cast.toString(args.STRING);
// Out of bounds?
if (index < 0 || index >= str.length) {
return '';
}
// `charAt` handles out of bounds by returning an empty string.
return str.charAt(index);
}