Add string contains string

This commit is contained in:
Ken 2017-08-11 00:52:41 +12:00 committed by GitHub
parent 3beebdc7be
commit 3b601e8595

View file

@ -30,6 +30,7 @@ class Scratch3OperatorsBlocks {
operator_join: this.join, operator_join: this.join,
operator_letter_of: this.letterOf, operator_letter_of: this.letterOf,
operator_length: this.length, operator_length: this.length,
operator_contains: this.contains,
operator_mod: this.mod, operator_mod: this.mod,
operator_round: this.round, operator_round: this.round,
operator_mathop: this.mathop operator_mathop: this.mathop
@ -106,6 +107,10 @@ class Scratch3OperatorsBlocks {
length (args) { length (args) {
return Cast.toString(args.STRING).length; return Cast.toString(args.STRING).length;
} }
contains (args) {
return Cast.toString(args.STRING1).includes(Cast.toString(args.STRING2));
}
mod (args) { mod (args) {
const n = Cast.toNumber(args.NUM1); const n = Cast.toNumber(args.NUM1);