From a3f1fb79567f10e0a6b2481fabfa2d2873364c1f Mon Sep 17 00:00:00 2001 From: Johan Milanov Date: Sat, 24 Feb 2024 18:10:52 +0100 Subject: [PATCH] Remove useless bounds check --- src/blocks/scratch3_operators.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/blocks/scratch3_operators.js b/src/blocks/scratch3_operators.js index 4fd6a7bf42b..cb4bf7b77a4 100644 --- a/src/blocks/scratch3_operators.js +++ b/src/blocks/scratch3_operators.js @@ -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); }